Skip to content

Instantly share code, notes, and snippets.

View geraudmathe's full-sized avatar

gerry geraudmathe

  • General Assembly
  • London
View GitHub Profile
@geraudmathe
geraudmathe / helloworld-rbmotion.rb
Created May 15, 2012 07:17
helloworld with rubymotion
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
alert = UIAlertView.new
alert.message = "Hello World!"
alert.show
true
end
end
@geraudmathe
geraudmathe / locomotive-fundamentals-classic-tree
Created May 19, 2012 09:34
locomotive fundamentals classic-tree
+- Views
+- layout
+- application
+- mysite
+- index
+- first page
+- second page
class Player
def initialize birthdate
@birthdate = birthdate
end
def is_old_enough?
birthdate < Date.today-18.years
end
end
{
"bold_folder_labels": true,
"color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
".DS_Store",
".gitkeep",
"dump.rdb"
],
class WDI
#setter
def name=name
@name = name
end
#getter
def name
@name
require 'benchmark'
n = 1000000
Benchmark.bm do |x|
x.report("Calling {} ") do
n.times{ hash = {} }
end
x.report("Calling Hash.new") do
n.times{ hash = Hash.new }
end
# COFFEE
@func
# JS
this.func
# COFFEE
@func()
# JS
this.func()
@geraudmathe
geraudmathe / ember_view_events.js
Last active December 21, 2015 04:28
how to bind the same function to differents events
App.MyView = Ember.View.extend({
tagName: "td",
my_function: function(){
alert("Do stuff here")
//in this context, you should be able to get content directly by the key , like this.get('myKey')
// and the controller is available via this.get('controller')
},
click: function(){
my_function()
def compute operation, a, b
result = case operation
when 'a'
"#{a + b}"
when 's'
"#{a - b}"
when 'm'
"#{a * b}"
when 'd'
"#{a / b}"
@geraudmathe
geraudmathe / gist:7335297
Created November 6, 2013 12:28
javascript common events
<!DOCTYPE html>
<html>
<head>
<title>Jquery events</title>
<style>
#mouseHover{ width:500px; height: 500px; background-color: red}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function(){