This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CJGGridView.h | |
// | |
// | |
// Created by Conor Griffin on 30/12/2013. | |
// Copyright (c) 2013 Conor Griffin. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example #1a | |
public class Person { | |
private int age; | |
public Person(int age) { | |
this.age = age; | |
} | |
public void isAdultOrChild() { | |
System.out.println(this.age >= 18 ? "Adult" : "Child"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# COLORS | |
LIGHT_GRAY="\[\033[0;37m\]"; BLUE="\[\033[1;36m\]"; RED="\[\033[0;31m\]"; LIGHT_RED="\[\033[1;31m\]"; | |
GREEN="\[\033[0;32m\]"; WHITE="\[\033[1;37m\]"; LIGHT_GRAY="\[\033[0;37m\]"; YELLOW="\[\033[1;33m\]"; | |
# GIT PROMPT (http://gist.github.com/120804) | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/'; | |
} | |
function parse_git_status { | |
git status 2> /dev/null | sed -e '/(working directory clean)$/!d' | wc -l; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'set' | |
require 'benchmark/ips' | |
class Array | |
def process_old() | |
self.join(" ").split().uniq | |
end | |
def process_new_1() | |
unique = Set.new() | |
self.each { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'action_mailer' | |
ActionMailer::Base.smtp_settings = { | |
:address => 'smtp.gmail.com', | |
:port => 587, | |
:domain => 'gmail.com', | |
:user_name => '[email protected]', | |
:password => 'senders-gmail-app-password', | |
:authentication => :plain, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Explicit path from root of document | |
elements = doc.xpath("/html"\ | |
"/body"\ | |
"/div[@id='m1']"\ | |
"/div[@class='middle']"\ | |
"/div[@class='col1']"\ | |
"/div[@class='box1l']"\ | |
"/table[@class='cat']"\ | |
"/tr[td/a/img[@src='/i/ple1.gif'] and td/a[contains(@href,'Canon-EF-lenses')]]") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'set' | |
# NOTE: This requires the benchmark-ips gem | |
# In case you don't want to install this gem, here's sample output of this file | |
# Calculating ------------------------------------- | |
# Old 1: 9 i/100ms | |
# New 1: 4 i/100ms | |
# New 2: 8 i/100ms | |
# New 3: 8 i/100ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import re | |
""" | |
http://code.google.com/codejam/contest/32003/dashboard#s=p0 | |
""" | |
def process(current_case): | |
alien_number, source_language, target_language = current_case.split() | |
source_language = list(source_language) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Taken from http://duartes.org/gustavo/blog/post/system-calls/ | |
#include <sys/types.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
int main() | |
{ | |
pid_t p = getpid(); | |
printf("%d\n", p); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
class IPGenerator | |
public | |
def initialize(session_count, session_length) | |
@session_count = session_count | |
@session_length = session_length | |
@sessions = {} | |
end |
OlderNewer