Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Robayna kevinrobayna

View GitHub Profile
View elapsedTime.java
long start_time = System.nanoTime();
//whatever you want
long end_time = System.nanoTime();
double difference = (end_time - start_time)/1e6;
View allFilesinFolder.java
File folder = new File("your/path");
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
System.out.println("File " + listOfFiles[i].getName());
} else if (listOfFiles[i].isDirectory()) {
System.out.println("Directory " + listOfFiles[i].getName());
}
}
View AlwaysMountRootFSWithNoatime_MacOSX.sh
#!/bin/bash
# +----------------------------------------------------------------------+
# | |
# | Mount the root file system / with the option noatime |
# | |
# | By Philipp Klaus <http://blog.philippklaus.de> |
# | Tip found on <http://blogs.nullvision.com/?p=275> |
# | |
# +----------------------------------------------------------------------+
View times.js
function times( x, y ) {
if ( x == 0 || y == 0 ) {
return z ( x );
}
else if ( y == 1 ) {
var g = function ( x ) {
return p ( arguments, 0 );
};
return g ( x );
}
View add
function add( x, y ) {
if ( y == 0 ) {
var g = function ( x ) {
return p ( arguments, 0 );
};
return g ( x );
}
else if ( y > 0 ) {
y --;
var h = function ( x, y, add_x_y ) {
@kevinrobayna
kevinrobayna / RemoveAccentsDiacritics.rb
Created May 26, 2014 09:14
Remove all accents and diacritics from string in Ruby
View RemoveAccentsDiacritics.rb
# coding: utf-8
from = "ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž"
to = "AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz"
line = line.tr(from,to)
View Grammar
%lex
%%
[\s\t\n\r] /** SKIP WHITESPACE */
<<EOF>> return 'EOF'
a return 'T_A';
b return 'T_B';
/lex
@kevinrobayna
kevinrobayna / Gemfile
Last active August 29, 2015 13:58 — forked from crguezl/Gemfile
View Gemfile
source :rubygems
gem 'sinatra'
gem 'json'
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-github'
# gem 'omniauth-att', :path => File.expand_path("./../../omniauth-att", __FILE__)
gem 'thin'
View WebAppExample.rb
require 'sinatra/base'
require 'haml'
require 'coffee-script'
require 'sass'
class WebAppExample < Sinatra::Base
set :root, File.dirname(__FILE__)
#Needed for CoffeeScript and SCSS