Skip to content

Instantly share code, notes, and snippets.

SELECT A.id, A.name, С.value
FROM apps AS A
LEFT JOIN link AS B
ON A.link_id=B.id
LEFT JOIN templates AS C
ON B.id=C.link_id
WHERE C.value IS NOT NULL
@sakal
sakal / gist:272b8811f73f154ab43e
Created February 6, 2015 10:36
python recusive default dict by Zart
>>> class rdict(dict):
... __missing__ = lambda self, key:self.setdefault(key, type(self)())
...
>>> d = rdict()
>>> d[1][2][3][4][5] = 'abc'
>>> d[1][2][3]['a']['b'] = 'def'
>>> d
{1: {2: {3: {4: {5: 'abc'}, 'a': {'b': 'def'}}}}}
# dpkg -l |grep glfw
ii libglfw3:amd64 3.0.4-1 amd64 portable library for OpenGL, window and input (libraries)
ii libglfw3-dev:amd64 3.0.4-1 amd64 portable library for OpenGL, window and input (development files)
def isgameover(self):
player1 = self.game.player1
player2 = self.game.player2
if (player1 and player2) is None:
raise Exception("Not initialized players")
for barisan in self.enumseq():
if self.iscontainfive(barisan, player1):
return True
if self.iscontainfive(barisan, player2):
>>> foo = dict([v, k] for k, v in enumerate(["HELO", "INSERT", "REMOVE", "QUIT"]))
>>> foo
{'INSERT': 1, 'HELO': 0, 'REMOVE': 2, 'QUIT': 3}
function test(x, y){
var arg = arguments;
return function(z){ console.log(arg[0], arguments[0]);};
}
var a = test(1,2);
a(3)
>> 1 3
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "GeForce 9600 GT"
BusID "PCI:1:0:0"
# Screen 0
EndSection
sakal@sakal:~$ xrandr -q
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 8192 x 8192
VGA-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 477mm x 268mm
1920x1080 60.0*+ 59.9
1920x1200 60.0
1680x1050 60.0 59.9
1600x1200 60.0
1440x900 59.9
1400x1050 60.0
1360x768 60.0 59.8
src = [{"id":1, "value":2}, {"id":3, "value":4}]
tmp_list = []
for item in src:
tmp_list.append({"id": item["id"], "value": item["value"]})
result = tuple(tmp_list)
@sakal
sakal / class_a.cpp
Created May 16, 2012 14:37
Use object as param for class method in cpp
#include <stdio.h>
#include "class_a.h"
A::A(void) {
}
A::~A(void) {
}