Skip to content

Instantly share code, notes, and snippets.

View 4e1e0603's full-sized avatar
🎯
I may be slow to respond.

David Landa 4e1e0603

🎯
I may be slow to respond.
  • Prague, Czech Republic
View GitHub Profile
@4e1e0603
4e1e0603 / python_syspath.md
Last active January 14, 2016 09:12
Prints the system path from a command line.

python -c "import sys; print('\n'.join(sys.path))"

@4e1e0603
4e1e0603 / postmkvirtualenv
Created January 14, 2016 12:25 — forked from jlesquembre/postmkvirtualenv
Creates a symlink to PyQt libraries when a new virtual environment is created
#!/bin/bash
# This hook is run after a new virtualenv is activated.
# ~/.virtualenvs/postmkvirtualenv
libs=( PyQt4 sip.so )
python_version=python$(python -c "import sys; print (str(sys.version_info[0])+'.'+str(sys.version_info[1]))")
var=( $(which -a $python_version) )
get_python_lib_cmd="from distutils.sysconfig import get_python_lib; print (get_python_lib())"
@4e1e0603
4e1e0603 / parser.py
Created February 22, 2016 14:55 — forked from JSONOrona/parser.py
Python command line argument example using argparse module
#!/usr/bin/python
''' Python command line argument example using argparse module
Example output:
./parser.py --server=pyserver --port=8080,443,25,22,21 --keyword=pyisgood
Server name: [ pyserver ]
@4e1e0603
4e1e0603 / singleton_export_instance.js
Created March 11, 2016 15:21
ES6 Singletons: Approach 1
class Person {
constructor() {
this.greeting = 'hello';
}
talk() {
alert(this.greeting);
}
var greeting = 'hello';
class Person {
constructor() {
throw 'You\'re trying to instantiate a singleton.';
}
static talk() {
alert(greeting);
@4e1e0603
4e1e0603 / sql_variadic_macro.cpp
Created July 15, 2016 19:35
C++/SQL variadic macro
#include <string>
#include <iostream>
#define SQL(...) #__VA_ARGS__
int main()
{
std::string query(SQL(
SELECT
*
@4e1e0603
4e1e0603 / endless_loop_with_quit.rs
Last active November 10, 2016 22:09
Run the endless loop and quit when the user types ':quit'.
use std::io::{BufRead};
fn main() {
println!("Type :quit<Enter> to quit this program.");
let stdin = std::io::stdin();
loop {
let line = stdin.lock().lines().next().unwrap().unwrap();
match line.as_ref() {
":quit" => std::process::exit(0),
_ => { break }
@4e1e0603
4e1e0603 / create-scala-project.bat
Last active November 16, 2016 14:28
Create the basic Scala/SBT project with Windows batch script.
@echo off
:: Create the basic SBT project structure.
:: Does not overwrite existing project folder.
:: Use the command `rd /s /q {folder-name}` for removing existing folder.
:: version 0.1
:: author: David Landa
:: license: http://creativecommons.org/licenses/by-sa/2.5/
@4e1e0603
4e1e0603 / DatabaseConnectionDemo.java
Last active November 21, 2016 20:56
Simple JDBC Java examples
/*
This example shows how to connect to PostgreSQL database server using the `DriverManager` class.
It is recommended to use `DataSource` class instead because of connection pooling.
compile: javac DatabaseConnectionDemo.java
execute: java -cp .;lib\postgresql-X.X.XXXX.jar DatabaseConnectionDemo
*/
//package io.uetoyo.gists;
@4e1e0603
4e1e0603 / rust-patterns-builder.rs
Last active November 19, 2016 17:57
Rust Builder Pattern Example
// Rust Builder Pattern Example
struct Foo {
x: i32,
y: i32,
z: i32
}
struct FooBuilder {
x: i32,