Skip to content

Instantly share code, notes, and snippets.

View Seich's full-sized avatar

David Díaz Seich

View GitHub Profile
@Seich
Seich / gist:1077044
Created July 11, 2011 23:26
Routs, Example 1
<?php
require 'routs.php';
Rout::get('home', 'homeFunction');
function homeFunction($params) {
templateManager::Render('home.tpl', $params);
}
?>
@Seich
Seich / gist:1077050
Created July 11, 2011 23:32
Routs, example 2
<?php
require 'routs.php';
Rout::get('home', 'homeFunction');
function homeFunction($params) {
templateManager::Render('home.tpl', $params);
}
Rout::post('home', function($params){
@Seich
Seich / about.md
Created August 10, 2011 23:11 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
public static string MakeValidFileName( string name )
{
string invalidChars = Regex.Escape( new string( Path.GetInvalidFileNameChars() ) );
string invalidReStr = string.Format( @"[{0}]+", invalidChars );
return Regex.Replace( name, invalidReStr, "_" );
}
@Seich
Seich / gist:1888634
Created February 23, 2012 00:22
Adding Nodes to Jtree
DefaultTreeModel model = (DefaultTreeModel)tree.getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)model.getRoot();
DefaultMutableTreeNode c1 = new DefaultMutableTreeNode("Cruce #1");
c1.add(new DefaultMutableTreeNode("Child 1"));
root.add(c1);
model.reload();
@Seich
Seich / batteryMeter.rb
Created March 3, 2012 19:06
Zsh battery reporting for Ubuntu
# encoding: utf-8
# Get the current battery status percentage.
battery_status = `acpi`
charge = battery_status.match(/\d*%/)[0].chop.to_i
# Calculate the number of charged slots.
total_slots = 10
filled = "▸" * (charge/total_slots).ceil
require "serialport"
@rfid_reader = SerialPort.new 4 # Open COM 5
@arduino = SerialPort.new 2 # Open COM 3
@valid_ids = ['4500B8D690BB']
def readRFID
rfid = @rfid_reader.gets
rfid.strip!
void setup () {
Serial.begin (9600);
pinMode (12, OUTPUT);
}
void serialEvent() {
digitalWrite(12, HIGH);
delay(2000);
digitalWrite(12, LOW);
Serial.read();
@Seich
Seich / gist:2934088
Created June 15, 2012 01:24
C++ 11 compile line for makefiles.
c11:
g++-4.6 -W -Wall -Wextra -pedantic -std=c++0x *.cc *.h
struct punto {
punto(int x1, int y1) : x(x1), y(y1) {}
int x;
int y;
};