Skip to content

Instantly share code, notes, and snippets.

public String toLowerCase(Locale locale) {
if (locale == null) {
throw new NullPointerException();
}
int firstUpper;
/* Now check if there are any characters that need to be changed. */
scan: {
for (firstUpper = 0 ; firstUpper < count; ) {
@zillou
zillou / cb.sh
Last active June 29, 2018 20:51
a wrapper function for xclip.
# A shortcut function that simplifies usage of xclip.
# - Accepts input from either stdin (pipe), or params.
# ------------------------------------------------
cb() {
local _scs_col="\e[0;32m"; local _wrn_col='\e[1;31m'; local _trn_col='\e[0;33m'
# Check that xclip is installed.
if ! type xclip > /dev/null 2>&1; then
echo -e "$_wrn_col""You must have the 'xclip' program installed.\e[0m"
# Check user is not root (root doesn't have access to user xorg server)
elif [[ "$USER" == "root" ]]; then
@zillou
zillou / nocaps.desktop
Created February 20, 2013 02:33
Remap caps lock as control
[Desktop Entry]
Encoding=UTF-8
Name=nocaps
Comment=Remap caps lock as control
Exec=setxkbmap -option ctrl:nocaps
Terminal=true
@zillou
zillou / vimrc
Created April 22, 2013 06:23
my vim config file
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
@zillou
zillou / shuffle.js
Created June 6, 2013 06:32
A jQuery plugin shuffle DOM elements
(function($) {
$.fn.shuffle = function() {
var allElems = this.get(),
getRandom = function(max) {
return Math.floor(Math.random() * max);
},
shuffled = $.map(allElems, function() {
var random = getRandom(allElems.length),
randEl = $(allElems[random]).clone(true)[0];
allElems.splice(random, 1);
def nav_link_to(link_text, link_path)
class_name = current_page?(link_path) ? 'selected' : ''
content_tag(:li, class: class_name) do
link_to link_text, link_path
end
end
@zillou
zillou / gist:9318757
Last active August 29, 2015 13:56
Set operations in Ruby
# filename spec/fake_set_spec.rb
require 'spec_helper'
require 'fake_set'
describe FakeSet, '#union' do
set1 = FakeSet.new(1, 2, 3)
set2 = FakeSet.new(3, 4, 5)
expect(set1.union(set2)).to eq FakeSet.new(1, 2, 3, 4, 5)
@zillou
zillou / fake_set.rb
Last active August 29, 2015 13:56
Fake set implementation in Ruby
# filename: spec/fake_set_spec.rb
require 'spec_helper'
require 'fake_set'
describe FakeSet, '#union' do
it "unions elements of two set" do
set1 = FakeSet.new([1, 2, 3])
set2 = FakeSet.new([3, 4, 5])
expect(set1.union(set2).data).to eq [1, 2, 3, 4, 5]
@zillou
zillou / navigating-ruby-files.md
Created July 20, 2014 02:52
Navigating Ruby Files with Vim

Navigating Ruby Files with Vim - The Cheat Sheet

Precision motions for Ruby

Look up Ruby motions by running :help ruby-motion.

command effect
@zillou
zillou / gist:fc70022928dea8a2a204
Last active August 30, 2015 07:06 — forked from masonforest/gist:4048732
Installing a Gem on Heroku from a Private GitHub Repo

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

  1. Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"