Skip to content

Instantly share code, notes, and snippets.

View jamornsriwasansak's full-sized avatar

Jamorn Sriwasansak jamornsriwasansak

View GitHub Profile
@jamornsriwasansak
jamornsriwasansak / reg_war.py
Created August 16, 2014 07:21
Reg chula warrior. Cri evri tim.
"""
Assuming, you launch reg_warrior from this file.
For first time. Setting up is required.
The modules in needed are
BeautifulSoup : Expand the features of html management in python
pygame : Play some files
The file in needed is
alert.mp3 : Your own alert sound
Placing in same level of dir with this file.
The variables' values in needed are
#!/usr/bin/python
import urllib2
import time
from ftplib import FTP
user = 'something'
host = 'www.something.com'
passwd = 'asdfjkl;asdfjkl;'
port = 2121
destination = '/domains/something.com/public_html/site'
package com.example.udpfootballer;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayDeque;
import android.util.Log;
package com.example.udpfootballer;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import android.util.Log;
public class UDPServer implements Runnable {
public int DEFAULT_PORT = 50003;
/*
* Copyright 2010, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
// glMatrix v0.9.5
glMatrixArrayType=typeof Float32Array!="undefined"?Float32Array:typeof WebGLFloatArray!="undefined"?WebGLFloatArray:Array;var vec3={};vec3.create=function(a){var b=new glMatrixArrayType(3);if(a){b[0]=a[0];b[1]=a[1];b[2]=a[2]}return b};vec3.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];return b};vec3.add=function(a,b,c){if(!c||a==c){a[0]+=b[0];a[1]+=b[1];a[2]+=b[2];return a}c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];return c};
vec3.subtract=function(a,b,c){if(!c||a==c){a[0]-=b[0];a[1]-=b[1];a[2]-=b[2];return a}c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];return c};vec3.negate=function(a,b){b||(b=a);b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];return b};vec3.scale=function(a,b,c){if(!c||a==c){a[0]*=b;a[1]*=b;a[2]*=b;return a}c[0]=a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;return c};
vec3.normalize=function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],g=Math.sqrt(c*c+d*d+e*e);if(g){if(g==1){b[0]=c;b[1]=d;b[2]=e;return b}}else{b[0]=0;b[1]=0;b[2]=0;return b}g=1/g;b[0]=c*g;b[1]=d*g;b[2]=e*g;return b};vec3.cross=function(a
@jamornsriwasansak
jamornsriwasansak / robot.cpp
Last active December 24, 2015 13:59
My Tracking Robo
int sensorRight = 0;
int sensorMid = 1;
int sensorLeft = 2;
int sensorLeftBound = 500;
int sensorRightBound = 500;
int sensorMidBound = 500;
int forwardCount = 0;
main() {
# Use colors, but only if connected to a terminal, and that terminal
# supports them.
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
#include <algorithm>
#include <cassert>
#include <vector>
#include "common\intersection.h"
#include "common\reflectcuts.h"
#include "common\accel.h"
#include "math\ray.h"
#include "math\math.h"
import numpy as np
import re
import sys
import matplotlib.pyplot as plt
def flip(m, axis):
if not hasattr(m, 'ndim'):
m = np.asarray(m)
indexer = [slice(None)] * m.ndim
try: