start new:
tmux
start new with session name:
tmux new -s myname
| #Newbie programmer | |
| def factorial(x): | |
| if x == 0: | |
| return 1 | |
| else: | |
| return x * factorial(x - 1) | |
| print factorial(6) | |
| #First year programmer, studied Pascal |
| EASY MARSHMALLOWS | |
| ----------------- | |
| Marshmallows are perhaps one of the simplest confections you can make. They only | |
| require a handful of ingredients, a batch can be thrown together in 10-15 minutes | |
| (plus *cough* 3 hours for them to set), and you can flavor them however you like. | |
| (You haven't LIVED until you've had coconut marshmallows!) | |
| Hardware needed: |
| # -------------------------------------------------------------------- | |
| # Recursive backtracking algorithm for maze generation. Requires that | |
| # the entire maze be stored in memory, but is quite fast, easy to | |
| # learn and implement, and (with a few tweaks) gives fairly good mazes. | |
| # Can also be customized in a variety of ways. | |
| # -------------------------------------------------------------------- | |
| # -------------------------------------------------------------------- | |
| # 1. Allow the maze to be customized via command-line parameters | |
| # -------------------------------------------------------------------- |
| # Easy to use: | |
| # | |
| # timer = LapTimer.new | |
| # # some task that might take awhile | |
| # timer.mark :step2 | |
| # # another task that needs timing | |
| # timer.mark :step3 | |
| # # and another task to time | |
| # timer.report | |
| # |
| import java.io.IOException; | |
| import java.lang.reflect.Method; | |
| import java.util.AbstractCollection; | |
| import java.util.ArrayList; | |
| import java.util.EnumSet; | |
| import java.util.HashMap; | |
| import java.util.Iterator; | |
| import java.util.Map; | |
| import android.media.AudioManager; | |
| import android.media.MediaPlayer; |
| # encoding: utf-8 | |
| s = "Blah \xe9 blah 헌글" | |
| puts "BEFORE" | |
| puts "encoding: #{s.encoding}" | |
| puts "valid : #{s.valid_encoding?}" | |
| puts "text : #{s}" | |
| s = s. |
| # Below are examples of how to initialize and use a Twitter::Client object for each Twitter user | |
| # Can initialize by passing in Hash of oauth_access information for the authenticated user driving calls | |
| # through Twitter4R | |
| twitter = Twitter::Client.new(:oauth_access => { | |
| :key => ACCESS_KEY, :secret => ACCESS_SECRET }) | |
| # Can also initialize by loading in file configuration file and specifying YAML key name to use for user: | |
| twitter = Twitter::Client.from_config("file/name/to/config.yml", "key") # YAML file will look like twitter.yml | |
| ##### STATUS APIs ###### |
| ;; based on core.logic 0.8-alpha2 or core.logic master branch | |
| (ns sudoku | |
| (:refer-clojure :exclude [==]) | |
| (:use clojure.core.logic)) | |
| (defn get-square [rows x y] | |
| (for [x (range x (+ x 3)) | |
| y (range y (+ y 3))] | |
| (get-in rows [x y]))) |
| # Sample implementation of quicksort and mergesort in ruby | |
| # Both algorithm sort in O(n * lg(n)) time | |
| # Quicksort works inplace, where mergesort works in a new array | |
| def quicksort(array, from=0, to=nil) | |
| if to == nil | |
| # Sort the whole array, by default | |
| to = array.count - 1 | |
| end |