This file contains 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
#!/bin/bash | |
# Shows branches with descriptions | |
branches=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's|refs/heads/||') | |
for branch in $branches; do | |
last_used=$(git show --pretty=format:"%Cgreen%cr%Creset" $branch | head -1) | |
desc=$(git config branch.$branch.description) | |
if [ $branch == $(git rev-parse --abbrev-ref HEAD) ]; then | |
branch="*\t$last_used\t\033[0;32m$branch\033[0m" | |
else |
This file contains 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 java.io.File; | |
import java.io.FileNotFoundException; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.net.URL; | |
import java.nio.channels.Channels; | |
import java.nio.channels.ReadableByteChannel; | |
import java.util.ArrayList; | |
import java.util.NoSuchElementException; |
This file contains 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
public class Restaurant { | |
public static void main(String args[]) throws InterruptedException { | |
Kitchen kitchen = new Kitchen(); | |
while (true) { | |
Order meal = kitchen.checkForFinished(); | |
System.out.println("Finished: " + meal); | |
// Maybe send a new order to the kitchen. | |
double rand = Math.random(); | |
if (rand < .1) { |
This file contains 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
public class SubwayLine { | |
public static void main(String[] args) { | |
Train local = new Train("C", 1, 16); | |
Train express = new Train("A", 3, 0); | |
for (int i = 0; i < 10; ++i) { | |
System.out.println("local: " + local.nextStop()); | |
System.out.println("express: " + express.nextStop()); |
This file contains 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 java.util.ArrayList; | |
public class Runner { | |
public static void main(String[] args) { | |
Person msM = new Teacher("Ms.", "M"); | |
ArrayList<Person> people = new ArrayList<Person>(); | |
people.add(msM); | |
msM.getName(); | |
((Teacher) msM).assignHomework(); |
This file contains 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 java.util.ArrayList; | |
public class Zoo { | |
public static void main(String[] args) { | |
ArrayList<Animal> animals = new ArrayList<Animal>(); | |
// Generate 100 random animals. | |
for (int i = 0; i < 100; i++) { | |
double randomNum = Math.random(); |
This file contains 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 time | |
import BaseHTTPServer | |
HOST_NAME = 'localhost' | |
PORT_NUMBER = 9000 # Choose a number > 1024. | |
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |
def do_GET(s): | |
"""Respond to a GET request.""" | |
s.send_response(200) |
This file contains 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
<?php | |
// inserts 1,000,000 docs in 14 seconds on a MacBook Pro running Ubuntu 9.04 | |
class Timer | |
{ | |
var $start; | |
var $pause_time; | |
/* start the timer */ |
This file contains 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
<?php | |
function getReplicationInfo($m) { | |
$db = $m->local; | |
$result = array(); | |
$ol = $db->system->namespaces->findOne(array("name" => 'local.oplog.$main')); | |
if ($ol && array_key_exists('options', $ol)) { | |
$result['logSizeMB'] = $ol['options']['size'] / 1000 / 1000; |
This file contains 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
#include <stdio.h> | |
#include "other.h" | |
#include "tester.h" | |
namespace other { | |
void other_type::some_method() { | |
printf("here\n"); | |
} | |
} |
OlderNewer