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
#include <stdio.h> | |
// Typedef for functions like "hi" | |
typedef int (*FPN)(int); | |
// Typedef for functions like "bye" | |
typedef int (*sFPN)(int, FPN); | |
// A function that takes an int num, and returns an int (num + 1) | |
int hi(int num) { | |
return num + 1; |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
typedef unsigned int u32; | |
typedef unsigned long long u64; | |
//------------------------------------------------------------------------- | |
// WorkArea | |
//------------------------------------------------------------------------- |
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
class Loan | |
def initialize(amount, term_in_months, rate) | |
@principle = amount | |
@term = term_in_months | |
@rate = rate | |
# Calcluate Initial Interest | |
@interest = some_formula | |
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
/** | |
* Adds a bindOverride and possibly bindOverrideGlobal [if bind global is installed] | |
* These methods override default broser behaviour before calling the callback | |
* | |
* usage: | |
* Mousetrap.bindGlobal('ctrl+s', _saveChanges); | |
*/ | |
Mousetrap = (function(Mousetrap) { | |
Mousetrap.bindOverride = function(keys, callback, action) { | |
var override_callback = function(e) { |
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 time_point(name) | |
$time_points ||= {} | |
$time_points[name] = [] if !$time_points.has_key? name | |
$time_points[name] << Time.now | |
end | |
def time_report | |
return if !defined? $time_points | |
report_time = Time.now | |
report = "Since %-30s: %f seconds" |
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
# Usage: | |
# class Thing | |
# def method_name(*args) | |
# args | |
# end | |
# alias_shift_arg(:method_changed, :method_name, 1, 2, 3) | |
# end | |
# thing = Thing.new | |
# thing.method_name("a").inspect #=> ["a"] | |
# thing.method_changed("a").inspect #=> [1, 2, 3, "a"] |
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
class OrderCoupon | |
include Mongoid::Document | |
field :code, type: String | |
field :discount, type: Integer | |
field :discount_type, type: String # Flat Price, Percentage | |
field :expiration, type: Date | |
belongs_to :order |
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
module ZZ | |
def self.prepended(target) | |
puts "included" | |
end | |
def hi | |
puts 123 | |
super | |
end | |
end | |
module CC |
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
class A | |
def normal | |
@a = nil | |
@a ||= 1 | |
end | |
def other_ | |
@b = nil | |
@b = 1 if !@b | |
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
# Extracts the SourceElementsNode within the function bodyof the | |
def extract_context() | |
@parser.extract({ | |
get: :value, | |
type: Array, | |
call: { | |
get: :first, | |
type: ExpressionStatementNode, | |
call: { | |
get: :value, |
OlderNewer