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 'shuffler_fm' | |
| require 'vlc-client' | |
| require 'ruby-progressbar' | |
| # requires a VLC media player installation | |
| # gem install shuffler_fm | |
| # gem install vlc-client | |
| # gem install ruby-progressbar | |
| # | |
| # ruby shuffler_fm.rb |
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
| (ns clojure-testdrive.object) | |
| (declare OBJECT) | |
| (declare ^:dynamic this) | |
| (defn new-object [klass] | |
| "Creates an object instance of a given class" | |
| (let [state (ref {})] | |
| (fn thiz [command & args] | |
| (condp = command | |
| :class klass |
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
Show hidden characters
| // installed Clojure packages: | |
| // | |
| // * BracketHighlighter | |
| // * lispindent | |
| // * SublimeREPL | |
| // * sublime-paredit | |
| { | |
| "word_separators": "/\\()\"',;!@$%^&|+=[]{}`~?", | |
| "paredit_enabled": true, |
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
| desc "tail log files" | |
| task :tail_logs, :roles => :app do | |
| trap("INT") { puts 'Interrupted'; exit 0; } | |
| run "tail -f #{shared_path}/log/#{rails_env}.log" do |channel, stream, data| | |
| puts # for an extra line break before the host name | |
| puts "#{channel[:host]}: #{data}" | |
| break if stream == :err | |
| end | |
| end |
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
| # encoding: UTF-8 | |
| Capistrano::Configuration.instance(:must_exist).load do | |
| namespace :rails do | |
| desc "Open the rails console on one of the remote servers" | |
| task :console, :roles => :app do | |
| hostname = find_servers_for_task(current_task).first | |
| exec "ssh -l #{user} #{hostname} -t 'source ~/.profile && #{current_path}/script/rails c #{rails_env}'" | |
| end | |
| end |
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
| $ rails console | |
| Loading development environment (Rails 3.0.6) | |
| ruby-1.8.7-p334 :001 > r = Rails.application.routes | |
| Gives you a handle of all the routes (config/routes.rb) | |
| #Inspect a named route: | |
| ruby-1.8.7-p334 :005 > r.recognize_path(app.destroy_user_session_path) | |
| => {:action=>"destroy", :controller=>"sessions"} |
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
| (ns three.demo) | |
| (def camera (THREE.Camera. 75 (/ window/innerWidth | |
| window/innerHeight) 1 10000)) | |
| (set! (.z (.position camera)) 1000) | |
| (def scene (THREE.Scene.)) | |
| (def geometry (THREE.CubeGeometry. 200 200 200)) | |
| (def obj (js/Object.)) | |
| (set! (.color obj) 0xff0000) | |
| (set! (.wireframe obj) true) | |
| (def material (THREE.MeshBasicMaterial. obj)) |
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 "sinatra/base" | |
| require "sinatra/namespace" | |
| require "multi_json" | |
| require "api/authentication" | |
| require "api/error_handling" | |
| require "api/pagination" | |
| module Api | |
| class Base < ::Sinatra::Base |
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
| (def history (Html5History.)) | |
| (.setUseFragment history false) | |
| (.setPathPrefix history "") | |
| (.setEnabled history true) | |
| (let [navigation (listen history EventType/NAVIGATE)] | |
| (go | |
| (while true | |
| (let [token (.-token (<! navigation))] | |
| (secretary/dispatch! token))))) |
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
| ;; | |
| ;; NS CHEATSHEET | |
| ;; | |
| ;; * :require makes functions available with a namespace prefix | |
| ;; and optionally can refer functions to the current ns. | |
| ;; | |
| ;; * :import refers Java classes to the current namespace. | |
| ;; | |
| ;; * :refer-clojure affects availability of built-in (clojure.core) | |
| ;; functions. |