Skip to content

Instantly share code, notes, and snippets.

View goFrendiAsgard's full-sized avatar

Go Frendi Gunawan goFrendiAsgard

View GitHub Profile
@goFrendiAsgard
goFrendiAsgard / try.py
Created March 20, 2014 17:51
SQLAlchemy and alembic
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
############################### SQL ALCHEMY SCRIPT ####################################
# create Base
Base = declarative_base()
# create Pokemon class
@goFrendiAsgard
goFrendiAsgard / extend_base.py
Created April 10, 2014 23:04
Extend SQL Alchemy's Base to avoid multiple inherritance
from sqlalchemy.ext.declarative import declarative_base, declared_attr
from sqlalchemy import Column, Integer, String
Base = declarative_base()
class CustomBase(Base):
__abstract__ = True
def __init__(self):
print "Hello world"
@goFrendiAsgard
goFrendiAsgard / Scaffold application in kokoropy
Created April 29, 2014 04:51
Scaffold application in kokoropy (just in case I run out idea about what complex situation I need to write)
python rossian.py scaffold-crud coba orang nama:String-50 alamat:String-50 ayah:orang:manytoone ibu:orang:manytoone teman:orang:onetomany anak:orang:onetomany jurus:jurus:onetomany pekerjaan:pekerjaan:manytoone hobi:hobi:manytomany tanggal_lahir:Date
@goFrendiAsgard
goFrendiAsgard / concurrency.go
Last active August 29, 2015 14:00
Try concurrency
package main
import (
"fmt"
"time"
)
func write(n int){
for i := 0; i<100; i++ {
@goFrendiAsgard
goFrendiAsgard / prof_04_01.java
Last active August 29, 2015 14:00
Superb-Linked-List (in java). I don't like to code in java. However sometime I have to. This is an example of how to make a superb-linked-list in java. The linked-list has both queue & stack mechanism, plus it support to push data on the correct order.
package prof_04_01;
class Node{
int data;
Node next;
Node prev;
public Node(int new_data){
data = new_data;
}
}
@goFrendiAsgard
goFrendiAsgard / face.py
Created June 19, 2014 05:13
OpenCV-Python haar classifier
import cv2
import numpy as np
c = cv2.VideoCapture(0)
# get the xmls from https://github.com/Itseez/opencv/tree/master/data/haarcascades
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')
while(1):
@goFrendiAsgard
goFrendiAsgard / reverse-number-set-in-xml.py
Created August 13, 2014 05:25
modify only some part of xml files (will be used for creating new HAAR-Classifier without even do the exhausting training process)
string = '''
<_>
<!-- root node -->
<feature>
<rects>
<_>3 7 14 4 -1.</_>
<_>3 9 14 2 2.</_></rects>
<tilted>0</tilted></feature>
<threshold>4.0141958743333817e-003</threshold>
<left_val>0.0337941907346249</left_val>
@goFrendiAsgard
goFrendiAsgard / gunvarrel 0.0.1
Created December 5, 2014 00:34
Arduino Push-Button & LED
/*
* Gunvarrel v 0.0.1
* Purpose: To emulate simple sonar robot
* Description: Far from perfect. I use LED instead of motor, and push-button instead of sonar
* Author: Go Frendi Gunawan
*/
int left_motor = 12; // left motor (now just LED)
int right_motor = 13; // right motor (now just LED)
int sonar_sensor = 8; // sonar (now just push-button)
@goFrendiAsgard
goFrendiAsgard / gunvarrel 0.0.2
Created December 5, 2014 05:33
Arduino Sonar Sensor & LED
/*
* Gunvarrel v 0.0.2
* Purpose: To emulate simple sonar robot
* Description: Far from perfect. I use LED instead of motor
* Author: Go Frendi Gunawan
*/
int left_motor = 12; // left motor
int right_motor = 13; // right motor
int sonar_trig = 8; // sonar trigger
int sonar_echo = 7; // sonar echo
/*
* Gunvarrel v 0.0.3
* Purpose: Simple sonar robot
* Description: Good enough
* Author: Go Frendi Gunawan
*/
int left_motor = 11; // left motor
int right_motor = 10; // right motor
int sonar_trig = 12; // sonar trigger
int sonar_echo = 13; // sonar echo