ict.ken.be

Delivering solid user friendly software solutions since the dawn of time.

Practical Mercurial - Notes 

Categories: Mercurial

Practical Mercurial by Rob Conery

Mastering mercurial

  • Only merge when you are ready.
  • Git's hostile and unfriendly! GUI Wanker vs l33t snob!
  • Team Foundation Server enforces workflow and needs licenses
  • Subversion needs centralized administrator.

Git

  • Github made git popular
  • Git more powerful but more complex to use
  • You need to tell git to remember an added file
  • More opiniated
  • Allows to alter history more
  • Pluralsight - Git Fundamentals by James Kovacs
  • Git in your browser: http://try.github.com
  • Pro Git Book by Scott Chacon: http://www.git-scm.com/book

Mercurial

  • Http-friendly
  • Visual tools
  • CodePlex
  • Google Code
  • Bitbucket.org
  • Hg is build on top python
  • TortoiseHg
  • VisualHg or Mercurial SCC

Create repository
.hg
Settings: merge tool, username (name <email>)
.hgignore (https://gist.github.com/314082)
Commit

Connect to remote repo
Sync - Configure - Add (alias)

Webserver select ssl required.

Commit - Open a new named branch
Commit all changes in branch
Select branch you want to merge into (eg. default)
Update
Make sure the current working directory is set to branch you want to merge into
Merge with
Commit

Push

.hgignore
syntax: glob
*.obj
[Bb]in
[Db]ebug*/

  • Settings - Changelog - Author Coloring
  • Settings - Sync - After pull do update

hgrc are the local repository settings that override your global settings
[ui]
username = Ken <mail@ken.be>

[tortoisehg]
authorcolor = True
postpull = update

The working directory

  • Use Update to switch between revisions

Fixing mistakes

  • You added a password or connectionstring to the repository
  • Undo last commit
  • There are extensions that allow you to change the history
  • Use revert when not commited

Sharing with google code
Add remote as alias
Push
Allows to add comments inline on the web
Side by side clone (vs github fork)
Naming: author-feature
Push changes to clone
Maintainer needs to pull clone and merge into main repository
All alias for repositories you want to pull from (make sure no update is done in those cases)

Merge conflicts

  • When you edit the conflict in winmerge the tortoisehg will think the merge is done.
  • If not you should click undo after returning from winmerge.
  • Then commit
  • All much faster then reintegrating a branch with subversion.

Working on a team

  • Setup smtp
  • Email patch (or export patch)
  • The patch is not mercurial dependend (hg import)
  • Hg Server (start webserver on port 8000)

Setup on your own iis

  • Download mercurial source + binaries
  • Download python (correct release for mercurial)
  • Install tortoisehg on server (optional)
  • Create directory for mercurial
  • Extract library.zip from source into this folder
  • Copy templates directory into this folder
  • copy hgweb.cgi & hgwebdir.cgi from binaries into this folder
  • Add correct read and execute for these files
  • Create sub directory repositories
  • Add write permissions to repositories directory for the user
  • Add hgweb.config: [paths] projects = \bla\bla\mercurial\repositories\**
  • IIS - Add website
  • Add handler mapping
  • CGI-exe *.exe
  • ISAPI-dll *.dll
  • *.cgi (normally *.py) to python.exe -u %s %s
  • Restrictions - Access - Execute
  • Edit Feature Permissions - Check Execute
  • Default document - hgwebdir.cgi
  • Basic Authentication Enable (disable anonymous)

Console

hg status
hg commit -m "Added another comment"
hg branch
hg branch "Issue13"
hg status
hg commit -m "Fixed 13"
hg update default
hg merge Issue13
hg commit -m "Merged 13"
hgtk log
hg revert --all
hg rollback

Use hg & hgtk as an external tool in visual studio this works easier then visualhg

Check-in notifications

  • Mostly done on the central repository
  • Edit hgrc file
  • Set smtp settings

[extensions]
hgext.notify=

[hooks]
changegroup.notify = python:hgext.notify.hook

[web]
baseurl = http://repo.foo.bar

[notify]
sources = push
test = False
template = Subject: [webroot|basename]: {desc|strip|firstline}\ndetails: {baseurl}...

config = /notify.config
OR
[usersubs]
rob@lala.com = *

[reposubs]
* = rob@lala.com

Rebasing

  • will graft the branch onto another, so it is no longer existing.

Add extensions to hgrc
[extensions]
rebase=

hg help rebase
hg update home_page (goto branch you want to attach)
hg branch (will show the branch you are in)
hg rebase -d default

Resources

Galaxy S3 USSD-Codes 

Categories: Security

*#06# Shows IMEI (International Mobile Equipment Identity) number
*#0*# LCD Test Menu
*#8999*523# LCD Brightness
*#1234# To check Software and Hardware information, PDA, CSC, MODEM (Firmware Version)
*#2222# H/W Version
*#*#4636#*#* user statistics and Phone Info
*#0011# Displays status information for the GSM
*#7780# Factory Reset
*2767*3855# Full factory reset (Don’t dial unless you have problem, it does not ask you to confirm )
*#12580*369# SW & HW Info
#*#8377466# S/W Version & H/W Version
#*2562# Restarts Phone
#*3849# Restarts Phone
#*3851# Restarts Phone
#*3876# Restarts Phone
#*5376# DELETE ALL SMS!!!!
*#197328640# Service Mode
*#0228# Battery status (ADC, RSSI reading)
*#32489# Service mode (Ciphering Info)
*#2255# Call List
#*3888# BLUETOOTH Test mode
#*7828# Task screen
*#5282837# Java Version
*#232337# Bluetooth MAC Adress
*#232331# Bluetooth Test Mode
*#232338# WLAN MAC Address
*#232339# WLAN Test Mode
*#8999*8378# Test Menu
*#0842# Vibra Motor Test Mode
*#0782# Real Time Clock Test
*#0673# Audio Test Mode
*#0*# General Test Mode
*#2263# RF Band Selection / Network modes select
*#9090# Diagnostic ConfiguratioN
*#7284# USB I2C Mode Control
*#872564# USB Logging Control
*#4238378# GCF Configuration
*#0283# Audio Loopback Control
*#1575# GPS Control Menu
*#3214789650# LBS Test Mode
*#745# RIL Dump Menu
*#746# Debug Dump Menu
*#9900# Takes you to System Dump, where Disabling Fast Dormancy gives a boost to your network speed on some networks (both wifi and Gprs), same code to re-enable it
*#44336# Sofware Version Info
*#0289# Melody Test Mode
*#2663# TSP / TSK firmware update
*#03# NAND Flash S/N
*#0589# Light Sensor Test Mode
*#0588# Proximity Sensor Test Mode
*#273283*255*3282*# Data Create Menu
*#273283*255*663282*# Data Create SD Card
*#3282*727336*# Data Usage Status
*#7594# Remap Shutdown to End Call TSK
*#34971539# Camera Firmware Update
*#526# WLAN Engineering Mode
*#528# WLAN Engineering Mode
*#7412365# Camera Firmware Menu
*#07# Test History
*#3214789# GCF Mode Status
*#272886# Auto Answer Selection
*#8736364# OTA Update Menu
*#301279# HSDPA/HSUPA Control Menu
*#7353# Quick Test Menu
*2767*4387264636# Sellout SMS / PCODE view
*#7465625# View Phone Lock Status
*7465625*638*# Configure Network Lock MCC/MNC
#7465625*638*# Insert Network Lock Keycode
*7465625*782*# Configure Network Lock NSP
#7465625*782*# Insert Partitial Network Lock Keycode
*7465625*77*# Insert Network Lock Keycode SP
#7465625*77*# Insert Operator Lock Keycode
*7465625*27*# Insert Network Lock Keycode NSP/CP
#7465625*27*# Insert Content Provider Keycode
*#272*IMEI# then we will get buyer code (For samsung galaxy sIII csc code)
*#*#7780#*#* Factory data reset - Clears Google-account data, system and program settings and installed programs. system will not be deleted, and OEM programs, as well as My Documents (pictures, music, videos)

TCP/IP Notes 

Categories: Network

Snel leren werken met TCP/IP
by Albrecht Becker

RFC 1541 about DHCP replaced by RFC 2131

ipv4 (32bit) vs ipv6 (128bit)

OSI-Model

  1. Physical: electricity, light, radio
  2. Datalink: crc
  3. Network: logic to physical, eg. MAC
  4. Transport: lost, duplicates, error free delivery, ...
  5. Session
  6. Presentation: encoding
  7. Application

Microsoft Stack

TCP:
connected with sequence and no duplicates
Winsock-app
Winsock-interface
connection, segments with sequence number
sender expects confirmation or resend
ports: 65536 (1024 first are well known ports)
20/21 ftp
23 telnet
25 smtp
80 www
110 pop3
139 NetBios

UDP:
without connection
NetBios-app: NetBEUI, IPX/SPX possible
NetBios over tcp/ip: net use \\UNC\...
broadcast, dns, rip, snmp, video, audio
69 TFTP
137 NetBios name service
138 NetBios datagram
161 SNMP

ARP: IP into MAC (Media Access Control - 48bits)

IP:
header: source ip, destination ip, tcp or udp, checksum, ttl

tracert

ICMP:
internet control message protocol (ping)
icmp source quench (when router overloaded, the clients should slow down)

IGMP:
internet group management protocol (multicast)
1-n (224.0.0.0) reduce bandwidth

LAN + WAN: frames

router/default gateway: replace source address with address of router

TTL: time to live, -1 for each router hop, mostly 32 seconds (up to 255 seconds), each router can subtract from it (on average 1-3s)

MAC: ipconfig /all

ARP:

  1. arp-cache: dynamic (max 10min) vs static (unlimited until reboot)
  2. broadcast on local network
  3. computer with ip will reply with it's MAC of the network card that has ip configured.
arp -a
arp -s ip MAC add
arp -d ip

www.internic.net (giving addressblocks to providers)

class A (eg. Apple, HP, IBM)
networkID: w
hostID: x.y.z
/8

class B (eg. M$, Exxon)
networkID: w.x
hostID: y.z
/16

class C
networkID: w.x.y
hostID: z
/24

class D
multicast

class E
testing

127.x.y.z: loopback addresses (16,7 milion)
w.x.y.255: broadcast addresses (eg. arp)
0.0.0.0: whole network (wildcard)
...1: mostly used for routers
subnets local network: 10.0.0.0; 172.16.0.0; 192.168.1.103

NAT: Network Address Translation 1-1 from pool of addresses (internal maps to real outside)
PAT: Port and Address Translation 1-n
Subnetmask decides what part of ip belongs to networkID and which to hostID
CIDR: Classless Interdomain Routing (number of zeroes at end of bitmask /x )
default gateway: local & remote ip different networkID.
peer-to-peer: workgroup network (name for logical grouping)
check if tcp/ip is setup correctly: ping 127.0.0.1
tcp/ip is server service on windows

subnets

254 hosts: 255.255.255.0
62 hosts: 255.255.255.192
14 hosts: 255.255.255.240
6 hosts: 255.255.255.248

routing

bridge allows broadcasts to pass through
router does not pass broadcasts

dynamic:
RIP (routing information protocol)
limited to 15 hops, for 10 to 50 networks
OSPF (open shortest path first)
will store information about neighboor routers

static:
route print
default gateway:
0.0.0.0 / 0.0.0.0 / 10.100.100.1 / IP / Metric (hops needed till destination)
if ip not found in routing table send to gateway
first in the list will be used unless unavailable
move routingtable to computer that is setup as default gateway
route add 10.100.40.0 mask 255.255.255.0 10.100.30.1
persist after reboot: route -p add

DHCP: dynamic host configuration protocol

server:
assigns ip addresses
subnetmasks
params for default gateway
lease
for DHCP initializing ports 67 and 68 need to be open

assigning:

  1. dhcp discover message (sourceip, destip, mac)
  2. dhcp offer message (ip broadcasted until client accepts)
  3. dhcp request (to all dhcp servers with ip of dhcp so other servers can release the ip)
  4. dhcp ack/nack
  5. on reboot only request & ack

lease:
after 50% of the lease, server will try and prolong until 3 misses (actually client is supposed to initiated)

auto addressing without dhcp server:
169.254.0.0 - 169.254.255.255
tries and uses if free
IP autoconfiguration can be enabled with a registry key

dhcp relay agent:
when network with more than 1 segment
will bypass router to the dhcp server
needed because dhcp broadcasts and they do not pass router

NetBios & WINS

before windows 2000
NETBEUI protocol (no routing)
convert computername into ip address

net use

name is 15 characters + peer byte

  • x00 workstation
  • x03 messaging
  • x20 server
  • x1b group
  • x?? user

return netbios name:

nbtstat -n
  1. local netbios cache
  2. nb nameserver
  3. broadcast
  4. lmhosts file
  5. hosts file
  6. dns

local netbios cache
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters
default 10min timeout
small: 16 names
large: 128 names

reload lmhosts:

nbstat -R
nbstat -a <remotecomputername>
ipconfig /all

LMHOSTS:
%systemroot%\System32\drivers\etc\LMHOSTS.SAM
#PRE puts into cache
#MH multihoned (computers with multiple network cards)

Hostname

max 255 alphanumeric tokens
ip / full qualified name / alias / alias / ...

DNS-Servers have partial database
Reverse dns lookup turns ip into hostnames
in-addr.arpa

Domain Name Space
Root .
TLD .edu, .org, .com (assign by icann.com)
Second Level Domain .microsoft (internic.net), .nl (denic.nl)
Subdomains or hostname .europe www
Hostname server01
FQDN: computername.[subdomain].secondleveldomain.topleveldomain
Nameserver:
gives ip to client for name through zone-file
primary vs secundary
cache-nameserver: does not contain zone-file

name conversion:

  • recursive: between client and local nameservers
  • iterative: client gets ip of another nameserver
  • inverse: in-addr.arpa (eg. 12.201.99.50.in-addr.arpa for ip 12.201.99.50)

zonedatabase:

  • a-record or host record: ip of host (select ptr record to allow reverse lookups)
  • ptr-record: pointer resource record
  • soa-record: start of authority to specify the primary name server, serienumber is to know if zonetransfer is needed, increase number by 1 for each change
  • ns-record: at least one (the soa-record), but can have additional name servers
  • cname-record: canonical name, alias for a-record
  • srv-record: location of services/protocols (eg. msdcs, _sites, _tcp, _udp)

you can configure multiple dns server for one network (fault tolerance)

nslookup <hostname>

Active Directory

users, computers, printers, release, ...
PDC: primary domain controller
BDC: backup domain controller
object + attributes
OU: organisational unit
The global catalog of a domain controller can be installed multiple times in the forest.

TCP/IP Troubleshoot

ping 127.0.0.1
ping local ip
ping gateway
ping host other network
ping netbios/hostname
tracert

To SSL or not to SSL 

Categories: IIS mojoPortal Security

To SSL or not to SSL, that is the question.
We are not running a bank, so my business doesn't need that. Does it?

Ano 2013, still millions of sites on the internet are running insecurely over http port 80 and who can blame them. Switching your site to https puts more pressure on your web server, makes your ranking in the SERP drop and on top of that it is a pain to get a good certificate working. Or so they say...

Graph of website hits after switching to ssl

So, let's check this out.

  1. yes, you will lose money while transfering serp ranking, it takes on average around one and a half month to transfer it. More of an issue is the fact that adsense doens't support https... yes dumb very dumb... you can change the protocol but then you do not comply with the agreement... yes, can't understand this one either. 
  2. difference in speed is only a few miliseconds, so no problem there
  3. yes, it is not easy to set up correctly when it is your first time

And last but not least, yes you should put your whole site on ssl. Well actually tls. And this means everything, not just parts of it or your users will get sslstripped away... so educate your users.

And then my checklist, the reason I am posting it here.

Testing with a self-signed certificate

Types:

  • Basic : one ip, one domain
  • Wildcard : one ip, one domain + subdomains
  • SAN aka UCC : one ip, multiple domains
  • SNI : multiple certificates on one ip (eg. not supported on IE for XP)

Requesting a certificate

  • Lot of personal details + calls
  • DNS records should match your personal details 

Import certificate and trust intermediate certificates

  • Especially Firefox doesn't like it, if you forget to trust the intermediates

IIS Settings

  • Bindings
  • Use an astriks * in front of the friendly name, so you can use the GUI to set the hostnames 
  • OR use appcmd set site /site.name:"<IISSiteName>" /+bindings. [protocol='https',bindingInformation='*:443:<hostHeaderValue>']
  • Rewrite with 301 (do not use 302)
  • Add strict security headers for HTST, and use chrome://net-internals to check if they are correct. (Strict-Transport-Security / max-age=16070400; includeSubDomains)

Additional settings for mojoPortal

  • SSLAvailable on true
  • SSLIsRequiredByWebserver (web.config) & Require SSL on All Pages (admin ui -> will update cannonical)
  • SSLCookies in two places + different cookie name
  • Robots file for ssl, you probably need same as default one
  • Test also for page that doesn't exists
  • If using paypal, make sure your update your url protocols

Update your content

  • <link rel='canonical' href='https...
  • using // for img and javascript
  • update your own links to https where posible
  • hopefully you don't use third party that doesn't support https
  • recommend and social links: point an og:url meta tag for both URLs to the https one

Update your webmaster tools

  • http and https are seen as different sites

more on https:

update (aug 2014)

Today google announced to take https into account for their search ranking. I hope they also do something about the adsense, but at least it is a step in the right direction. Read more at http://googlewebmastercentral.blogspot.be/2014/08/https-as-ranking-signal.html.

Drop all the tables, stored procedures, triggers, constraints and all the dependencies 

Categories: SQL Server

/* Drop all non-system stored procs */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])
WHILE @name is not null
BEGIN
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
PRINT 'Dropped Procedure: ' + @name
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 AND [name] > @name ORDER BY [name])
END
GO

/* Drop all views */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'V' AND category = 0 ORDER BY [name])
WHILE @name IS NOT NULL
BEGIN
SELECT @SQL = 'DROP VIEW [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
PRINT 'Dropped View: ' + @name
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'V' AND category = 0 AND [name] > @name ORDER BY [name])
END
GO

/* Drop all functions */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] IN (N'FN', N'IF', N'TF', N'FS', N'FT') AND category = 0 ORDER BY [name])
WHILE @name IS NOT NULL
BEGIN
SELECT @SQL = 'DROP FUNCTION [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
PRINT 'Dropped Function: ' + @name
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] IN (N'FN', N'IF', N'TF', N'FS', N'FT') AND category = 0 AND [name] > @name ORDER BY [name])
END
GO

/* Drop all Foreign Key constraints */
DECLARE @name VARCHAR(128)
DECLARE @constraint VARCHAR(254)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY TABLE_NAME)
WHILE @name is not null
BEGIN
SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
WHILE @constraint IS NOT NULL
BEGIN
SELECT @SQL = 'ALTER TABLE [dbo].[' + RTRIM(@name) +'] DROP CONSTRAINT [' + RTRIM(@constraint) +']'
EXEC (@SQL)
PRINT 'Dropped FK Constraint: ' + @constraint + ' on ' + @name
SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' AND CONSTRAINT_NAME <> @constraint AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
END
SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY TABLE_NAME)
END
GO

/* Drop all Primary Key constraints */
DECLARE @name VARCHAR(128)
DECLARE @constraint VARCHAR(254)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' ORDER BY TABLE_NAME)
WHILE @name IS NOT NULL
BEGIN
SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
WHILE @constraint is not null
BEGIN
SELECT @SQL = 'ALTER TABLE [dbo].[' + RTRIM(@name) +'] DROP CONSTRAINT [' + RTRIM(@constraint)+']'
EXEC (@SQL)
PRINT 'Dropped PK Constraint: ' + @constraint + ' on ' + @name
SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' AND CONSTRAINT_NAME <> @constraint AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
END
SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' ORDER BY TABLE_NAME)
END
GO

/* Drop all tables */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'U' AND category = 0 ORDER BY [name])
WHILE @name IS NOT NULL
BEGIN
SELECT @SQL = 'DROP TABLE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
PRINT 'Dropped Table: ' + @name
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'U' AND category = 0 AND [name] > @name ORDER BY [name])
END
GO

Page 12 of 43 << < 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 20 40 > >>