Skip to content

Instantly share code, notes, and snippets.

View deostroll's full-sized avatar
😄
indeed...!

arun.jayapal deostroll

😄
indeed...!
View GitHub Profile
@deostroll
deostroll / python interpreter
Created July 8, 2012 16:57
output from python interpreter while trying out GitPython
>>> from git import *
>>> repo = Repo(
... "C:\Users\deostroll\Documents\GitHub\synchost")
>>> repo
<git.Repo "C:\Users\deostroll\Documents\GitHub\synchost\.git">
>>> repo.is_dirty()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\git\repo\base.py", line 502, in is_dirty
len(self.git.diff('HEAD', '--cached', *default_args)):
struct EnumWindowsCallbackArgs {
EnumWindowsCallbackArgs( DWORD p ) : pid( p ) { }
const DWORD pid;
std::vector<HWND> handles;
};
EnumWindowsCallbackArgs args( ::GetCurrentProcessId() );
@deostroll
deostroll / dynamic function example
Created July 29, 2012 07:39
writing dynamic functions in the python interpreter
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def print_hello():
... print 'Hello foo world'
...
>>> print_hello()
Hello foo world
>>> #some other arbitary function call
... #will result in an error
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.getcwd()
'/home/deostroll'
>>>
@deostroll
deostroll / gist:3196562
Created July 29, 2012 07:52
example of how import works
$ cd ~/scripts/tmp
$ touch m1.py
$ pico m1.py
$ cat m1.py
print 'Imported module m1'
def m1foo():
print 'executed m1 foo'
$ python
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace caNewtonsoftJson
{
class Person
{
public string Name { get; set; }
public int Age { get; set; }
@deostroll
deostroll / time.js
Created October 31, 2014 10:08
javascript print time in hh:mm:ss format - simple way
(function(dt) {
return [dt.getHours(), dt.getMinutes(), dt.getSeconds()].map(function(n) {
return n < 10 ? '0' + n : n
}).join(':');
})(new Date())
@deostroll
deostroll / comb.py
Last active August 29, 2015 14:16 — forked from anonymous/comb.py
Simple combinations using python
from math import factorial as fact
def comb(seq, r):
n = len(seq)
total = fact(n) / (fact(r) * fact(n-r))
pos = range(r)
c= []
i = 0
while i < total:
c.append(map(lambda x: seq[x], pos))
@deostroll
deostroll / comb.py
Last active August 29, 2015 14:16 — forked from anonymous/comb.py
Combinations in python using a generator
from math import factorial as fact
def comb(seq, r):
n = len(seq)
total = fact(n) / (fact(r) * fact(n-r))
pos = range(r)
#c= []
i = 0
while i < total:
#c.append(map(lambda x: seq[x], pos))
@deostroll
deostroll / Combinations.java
Created February 26, 2015 05:53
Generic Combination implementation in java
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class Combinations<T> implements Iterable<ArrayList<T>> {
private int totalCombinations;
private int n, r;
private int factorial(int n) {