Change the current branch to master in git 

git checkout better_branch
git merge --strategy=ours master # keep the content of this branch, but record a merge
git checkout master
git merge better_branch # fast-forward master up to the merge


stackoverflow source

git doc on merging and branching


[ add comment ] ( 2 views )   |  [ 0 trackbacks ]   |  permalink  |  related link
Bootstrap 
Sleek, intuitive, and powerful front-end framework for faster and easier web development


[ add comment ] ( 3 views )   |  [ 0 trackbacks ]   |  permalink  |  related link
Linux: tc is NOT dark magic (as i though) 
show traffic stats for pools

tc -s class show dev eth1


class htb 1:1111 parent 1:1 prio 0 rate 40000bit ceil 8152Kbit burst 1600b cburst 1598b
Sent 947099 bytes 886 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 163 borrowed: 708 giants: 0
tokens: 4750000 ctokens: 23313

class htb 1:1110 parent 1:1 prio 0 rate 40000bit ceil 8152Kbit burst 1600b cburst 1598b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: 5000000 ctokens: 24531

tccs is a parser for tc statistic output. the script copy is below:


#!/usr/bin/perl -w

# copyright 2005-2008 Tomasz Pala <gotar@pld-linux.org>
# license: GPL

# usage:
# watch -d -n1 'tc -s c ls dev imq1 | tccs -f 10 2>/dev/null'

# tccs.rc file format:
# %translate = ( '1:2' => 'LAN', '1:4076' => 'pc76', '1:b238' => 'VoIP-3_29 );


#use strict;
use Getopt::Long;

#tc -s class show dev eth1 | perl -e 'undef $/; while(<>) { while (/class htb (.*?) .*?\n\s*Sent (\d+) .*?\n\s*rate (\d+)/sg) { print "Klasa: $1 Wyslano: $2 ($3bps)\n" }; };'

my $class;
my $classid;
my $parent;
my $rate;
my $ceil;
my $crate;
my $sent;
my $range;
my %tree;
my $recurse=10;
my $speedlevel=0;
my %translate;

eval `cat tccs.rc 2>/dev/null`;

GetOptions('recurse=s'=>\$recurse,
'fastest=s'=>\$speedlevel);

while(<STDIN>) {
if(/^ lended: / and $crate) {
if($rate ne $ceil) {
$range="$rate-$ceil";
} else {
$range=$rate;
}
# print "$parent: $class $classid $range $crate kb/s\n";
@{$tree{$parent}}[0]='' unless @{$tree{$parent}}[0];
push @{$tree{$parent}}, $classid;
$crate=sprintf "%8.1lf",$crate;
$sent=sprintf "%10.0lf",$sent/1024;
@{$tree{$classid}}[0]="($class) $range $crate kb/s ($sent KB)";
$crate=0;
next;
}
if(/^ Sent (\d+) bytes /) {
$sent=$1;
next;
}
if(/^ rate (\S+)(bit|bps) /) {
# print "BPS rate!\n" if $2 eq "bps";
if ($2 eq "bps") {
($crate=$1)=~s/K/*1024/;
$crate=~s/M/*1024*1024/;
$crate=eval $crate;
$crate*=8/1000;
} else {
($crate=$1)=~s/K/*1000/;
$crate=~s/M/*1000*1000/;
$crate=eval $crate;
$crate/=1000;
}
next;
}
if(/^class (\S+) (\S+:\S+) (root|parent (\S+:\S+)) .*rate (\S+) ceil (\S+)/) {
$class=$1;
$classid=$2;
$rate=$5;
$ceil=$6;
($parent=$3)=~s/parent //;
next;
}
}

my $level='';

sub my_sort {
return 0 unless $_[0];
return $_[0] cmp $_[1] unless $speedlevel;
return -1 if($a=~/^\(/);
$tree{$_[0]}[0]=~m|\(\S+\)\ \S+ \s*([\d\.]+) kb/s \(|;
my $a=$1;
$tree{$_[1]}[0]=~m|\(\S+\)\ \S+ \s*([\d\.]+) kb/s \(|;
my $b=$1;
return $b <=> $a;
}

sub list {
return if length($level)/2==$recurse;
if($_[0]) {
if(exists $translate{$_[0]}) {
printf "$level%-4s",$translate{$_[0]};
} else {
printf "$level%-4s",$_[0];
}
} else { return; }
$level.=' ';
my $rank=0;
foreach my $id (sort {my_sort($a,$b)} (@{$tree{$_[0]}})) {
if($id=~/^\(/) {
print " $id\n";
next;
} else {
$rank++;
next if $rank>$speedlevel and $speedlevel;
list($id);
}
}
$level=substr($level,2);
}

#@{$tree{'root'}}[0]="\n";
#list('root');
if(defined $tree{'root'}) {
foreach (sort {my_sort($a,$b)} (@{$tree{'root'}})) {
list($_);
}
}





htb example, htb documentation

For details refer to the HTB Home Page

#!/bin/sh
#
# Incoming traffic control
#
CT_IP1=$1
CT_IP2=$2
DEV=venet0
#
tc qdisc del dev $DEV root
#
tc qdisc add dev $DEV root handle 1: htb default 10
#
tc class add dev $DEV parent 1: classid 1:1 htb rate 100mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 10mbit ceil 10mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 20mbit ceil 20mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 30mbit ceil 30mbit burst 15k
#
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
#
if [ ! -z $CT_IP1 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dst "$CT_IP1" flowid 1:20
fi
if [ ! -z $CT_IP2 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dst "$CT_IP2" flowid 1:30
fi
#
echo;echo "tc configuration for $DEV:"
tc qdisc show dev $DEV
tc class show dev $DEV
tc filter show dev $DEV
#
# Outgoing traffic control
#
DEV=eth0
#
tc qdisc del dev $DEV root
#
tc qdisc add dev $DEV root handle 1: htb default 10
#
tc class add dev $DEV parent 1: classid 1:1 htb rate 100mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 10mbit ceil 10mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 20mbit ceil 20mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 30mbit ceil 30mbit burst 15k
#
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
#
if [ ! -z $CT_IP1 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip src "$CT_IP1" flowid 1:20
fi
if [ ! -z $CT_IP2 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip src "$CT_IP2" flowid 1:30
fi
#
echo;echo "tc configuration for $DEV:"
tc qdisc show dev $DEV
tc class show dev $DEV
tc filter show dev $DEV

Twisted is an event-driven networking engine written in Python

[ add comment ] ( 3 views )   |  [ 0 trackbacks ]   |  permalink  |  related link
saw tooth 
the saw tooth generator with dco can be produced by connecting the tranzistor to the circuit in the video.



analog filters quick guide by ti
http://www.ti.com/lit/an/sloa093/sloa093.pdf

square wave to sine wave
http://www.electronicspoint.com/attachm ... output.jpg


[ add comment ] ( 5 views )   |  [ 0 trackbacks ]   |  permalink
Django custom view into admin page 
http://stackoverflow.com/questions/5693 ... admin-page


[ add comment ] ( 5 views )   |  [ 0 trackbacks ]   |  permalink
python copy deepcopy 
http://stackoverflow.com/questions/2612 ... -in-python

[ add comment ] ( 5 views )   |  [ 0 trackbacks ]   |  permalink
Django admin list instances of model 
In Django admin index page normally,the app and it's models will be listed.But Just to know How to list the model objects in this index page? Just Instead of the displaying app just i wanna display the it's model objects? How it should be customized?


http://stackoverflow.com/questions/7505 ... el-objects


[ add comment ] ( 5 views )   |  [ 0 trackbacks ]   |  permalink  |  related link
Django Admin customization plugins 
Grappelli is a grid-based alternative/extension to the Django administration interface.


https://github.com/sehmaschine/django-grappelli


django-admin-tools is a collection of extensions/tools for the default django administration interface, it includes:

a full featured and customizable dashboard;
a customizable menu bar;
tools to make admin theming easier.



https://bitbucket.org/izi/django-admin-tools/wiki/Home

[ add comment ] ( 5 views )   |  [ 0 trackbacks ]   |  permalink
python: signals 
On Wed, 15 Sep 2004, Kent Johnson wrote:

> If you return from the handler, processing will continue where it was
> interrupted. If you want to inspect the frame object in your handler, some
> information about it is available here:
> http://docs.python.org/ref/types.html#l2h-142
>
> For example, running this program in IDLE on MacOSX:
> #############################
> import signal
>
> done = 0
> def handler(signum, frame):
> print frame
> print dir(frame)
> print 'Signal handler called with signal', signum
> global done
> done = 1
>
> # Set the signal handler and an alarm
> signal.signal(signal.SIGALRM, handler)
> signal.alarm(3)
>
> print "Looping"
> while not done:
> pass
>
> print "Out of loop"
>
> signal.alarm(0) # Disable the alarm
>
> print "Done"
> ##############################3
>
> gives this output:
> >>> ================================ RESTART ================================
> >>>
> Looping
> <frame object at 0x4fd6c0>
> ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__',
> '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
> '__setattr__', '__str__', 'f_back', 'f_builtins', 'f_code',
> 'f_exc_traceback', 'f_exc_type', 'f_exc_value', 'f_globals', 'f_lasti',
> 'f_lineno', 'f_locals', 'f_restricted', 'f_trace']
> Signal handler called with signal 14
> Out of loop
> Done
> >>>
>
> Kent
>


[ add comment ] ( 7 views )   |  [ 0 trackbacks ]   |  permalink
Django - Overriding save() method in Model 
http://stackoverflow.com/questions/4574 ... d-in-model

[ add comment ] ( 5 views )   |  [ 0 trackbacks ]   |  permalink

<<First <Back | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | Next> Last>>