This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Singleton(type): | |
| def __init__(cls, name, bases, dic): | |
| super(Singleton,cls).__init__(name,bases,dic) | |
| cls.instance = None | |
| def __call__(cls,*args,**kw): | |
| if cls.instance is None: | |
| cls.instance=super(Singleton,cls).__call__(*args,**kw) | |
| return cls.instance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *.pyc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| N = int(sys.argv[1]) | |
| print (lambda n,f: f(n-1, f) + f(n-2, f) if n>2 else 1) \ | |
| (N, lambda n,f: f(n-1,f)+f(n-2,f) if n>2 else 1 if n>2 else 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from StringIO import StringIO | |
| import re | |
| import itertools | |
| s = 'text1 text2 /* asdasd */ text3 /* /*asdasd */ text4' | |
| BLOCK = 6 # even number! | |
| OPEN = 1 | |
| CLOSE = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if ! nmcli con status id HomeVPN &>/dev/null; then | |
| nmcli con up id HomeVPN | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IFS=$'\n' | |
| BASE="http://www.wwii-photos-maps.com/kievaerialscans/GX3938SG%282%29-260943/" | |
| index=1 | |
| for x in `curl "$BASE/index.html" 2>/dev/null | grep -io 'slides/.*html'`; do | |
| for img in $(curl -L `echo "${BASE}${x}" | sed 's/ /%20/'` 2>/dev/null | grep -ioP 'src=".*?jpg"' | grep -v thumbs | sed -r "s/src=\"(.*)\"/\1/g"); do | |
| curl "$BASE/slides/$img" > "$index-$img" | |
| index=$((index+1)) | |
| done | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| LIBRARY ieee; | |
| USE ieee.std_logic_1164.all; | |
| LIBRARY work; | |
| ENTITY Custom_FSM IS | |
| PORT | |
| ( | |
| clk : IN STD_LOGIC; | |
| init : IN STD_LOGIC; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class A(object): | |
| def m(self): | |
| print 'A1' | |
| try: | |
| super(A, self).m() | |
| except AttributeError: | |
| print 'A has no super.m()!' | |
| print 'A2' | |
| class B(object): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket, threading | |
| host = "127.0.0.2" | |
| server = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP) | |
| remote, peer = None, None | |
| server.bind((host, 0)) | |
| server_addr = server.getsockname() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
OlderNewer