Skip to content

Instantly share code, notes, and snippets.

View edthix's full-sized avatar
💭
Online

Edham Arief Dawillah / edthix edthix

💭
Online
View GitHub Profile
@edthix
edthix / gist:3687488
Created September 9, 2012 21:41
Pick a state
private int get_state_index(string state) {
if(state == "AL")
return 0;
if(state == "AK")
return 1;
if(state == "AZ")
return 2;
if(state == "AR")
return 3;
if(state == "CA")
@edthix
edthix / gist:6147624
Created August 3, 2013 19:11
Some perspective on Clojure's quote, ' (single quote) and syntax quote ` (back quote)
(ns my-app.core)
;; Clojure 1.5
(quote hello 1 2 3 we are martians) ;; returns hello
'(hello 1 2 3 we are martians) ;; returns (hello 1 2 3 we are martians)
`(hello 1 2 3 we are martians) ;; (my-app.core/hello 1 2 3 my-app.core/we my-app.core/are my-app.core/martians)
# Run in idle (Windows 7, python 2.7) everything ok until table definition
>>> from sqlalchemy import create_engine, MetaData
>>> from sqlalchemy.orm import scoped_session, sessionmaker
# user/password/database I put it wrongly since this is public
>>> engine = create_engine('mssql+pyodbc://plast@user:password@database', convert_unicode=True, implicit_returning=False)
>>> metadata = MetaData(bind=engine)

New Ruby software project procedure

First, ensure the following tools are available on the local system and reasonably up to date:

  • Git
  • Git-flow
  • RVM
  • Bash
  • SSH
@edthix
edthix / arduino_robot_sr04.ino
Created November 16, 2015 13:56
Arduino Robot + SR04 example
#include <ArduinoRobot.h>
#include <SPI.h>
#include "Wire.h"
/*
* Arduino Robot + SR04 example
*/
#define echoPin TKD3
#define trigPin TKD4
@edthix
edthix / arduino_robot_sr04_3_sensors.ino
Created November 18, 2015 14:14
Arduino Robot + SR04 x 3 example
#include <ArduinoRobot.h>
#include <SPI.h>
#include "Wire.h"
/*
* Arduino Robot + SR04 example
*/
// sensor1
#define echoPin1 TKD1
@edthix
edthix / video.xml
Created January 23, 2018 08:17
Some video xml
<?xml version="1.0" encoding="UTF-8"?>
<Mediainfo
version="0.1"
ref="../Videos/WCKKDEMO.mp4">
<File>
<track type="General">
<Count>325</Count>
<Count_of_stream_of_this_kind>1</Count_of_stream_of_this_kind>
<Kind_of_stream>General</Kind_of_stream>
<Kind_of_stream>General</Kind_of_stream>
<?xml version="1.0" encoding="UTF-8"?>
<Mediainfo
version="0.1"
ref="sources/234p_0.ts">
<File>
<track type="General">
<Count>324</Count>
<Count_of_stream_of_this_kind>1</Count_of_stream_of_this_kind>
<Kind_of_stream>General</Kind_of_stream>
<Kind_of_stream>General</Kind_of_stream>
<?xml version="1.0" encoding="UTF-8"?>
<Mediainfo
version="0.1"
ref="sources/234p_0.ts">
<File>
<track type="General">
<Count>324</Count>
<Count_of_stream_of_this_kind>1</Count_of_stream_of_this_kind>
<Kind_of_stream>General</Kind_of_stream>
<Kind_of_stream>General</Kind_of_stream>
@edthix
edthix / ssh_tunnel_postgres.py
Created December 11, 2019 08:12
Sample airflow dag for ssh tunnel + postgres (assuming both SERVER_ssh_connector and SERVER_ssh_postresql_tunnel_connector are available)
from datetime import timedelta, datetime
import airflow
from airflow import DAG
from airflow.models import Variable
from airflow.contrib.operators.ssh_operator import SSHOperator
from airflow.contrib.hooks.ssh_hook import SSHHook
from airflow.operators.postgres_operator import PostgresOperator
default_args = {
'owner': 'airflow',