Skip to content

Instantly share code, notes, and snippets.

View ksol's full-sized avatar
🏠
Working from home, most of the time

Kevin Soltysiak ksol

🏠
Working from home, most of the time
  • Scalingo
  • Strasbourg, France
  • 23:57 (UTC +02:00)
  • X @ksol
View GitHub Profile
// Caller, a subclass of UITableViewCell. Only have a method
- (void) drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorRef whiteColor = [UIColor whiteColor].CGColor;
CGColorRef lightGrayColor = [UIColor colorWithRed:230.0/255.0
green:230.0/255.0
blue:230.0/255.0
alpha:1.0].CGColor;
@ksol
ksol / with_options_demo.rb
Created July 15, 2012 14:52
with_options demo
## Classic
accepts_nested_attributes_for :addresses, reject_if: :all_blank, allow_destroy: true
accepts_nested_attributes_for :client_detail, reject_if: :all_blank, allow_destroy: true
## with_options
with_options reject_if: :all_blank, allow_destroy: true do |u|
u.accepts_nested_attributes_for :addresses
u.accepts_nested_attributes_for :client_detail
end
ary = [1, 2, 3]
_.each(ary, function(item) { console.log(item); })
_(ary).each(function(item) { console.log(item); })
@ksol
ksol / congrats.rake
Created August 17, 2012 07:39
SO question
namespace :mailers do
desc 'Send the "congrats" mail'
task congrats: :environment do
lists = Photobook.distinct_list_for_date Date.yesterday
lists.each do |list|
book = list.most_recent_book
if book.present?
mailer = Routines.congrats(book)
@ksol
ksol / aliases.sh
Created May 27, 2013 07:57
Ruby/rails powered shell aliases. Used with zsh, but should work with bash too.
# Classic aliases
alias bx='bundle exec'
alias bs='bundle show'
alias bu='bundle update'
alias bo='bundle open'
alias bxsc='bundle exec script/console'
alias bxrc='bundle exec rails console'
alias bxcs='bundle exec cap staging'
alias bxcp='bundle exec cap production'
15:12:41] <ksol> les potes de mon asso étudiant s'occupent de l'accueil des nouveaux rentrants la
[15:13:03] <ksol> et chaque année ils font un faux cours avec un vrai (ou faux) prof qui les bullshit durant une demi heure pour les faire flipper leurs mère
[15:13:16] <ksol> cette année ils en ont pas trouvé, et j'me suis proposé
[15:13:16] <@lda> haha ok
[15:13:33] <ksol> je prends vos idées stupides, je sais que y'en a à revendre par ici
[15:16:06] <@lda> c'est quel genre de BS qu'il te faut ?
[15:20:34] <ksol> bah hm par exemple, y'a quelques années, un prof faisait un cours sur la complexité et les classes de complexité
[15:20:51] <ksol> et du fait que y'avait de nouvelles classes qui étaient apparues suite à internet, tout ça
[15:25:44] <ksol> notamment les modulations embarquées (modem), les unifications de modulations postérieures (ump), bref, tu vois le genre
[15:25:49] <ksol> bref, je pensais faire un truc utile
[ksol@Thrace] [1.8.7-p358 4.1.0 master] $ irb
irb(main):001:0> RUBY_VERSION
=> "1.8.7"
irb(main):002:0> hsh = {:a => 1}
=> {:a=>1}
irb(main):003:0> hsh[:a] = nil
=> nil
irb(main):004:0> hsh
=> {:a=>nil}
@ksol
ksol / gist:b52cf88899635ea72fb8
Created June 27, 2014 13:53
Override Ember Data application adapter to force the use of .json extension
MyApp.ApplicationAdapter = DS.RESTAdapter.extend({
buildURL: function() {
var base;
base = this._super.apply(this, arguments);
return "" + base + ".json";
}
});
@ksol
ksol / 1_index_route.coffee
Last active August 29, 2015 14:03
Example of Ember.PromiseMixin usage
Application.IndexRoute = Ember.Route.extend
sections:
label1: url1
label2: url2
label3: url3
labels: (->
Ember.keys @get('sections')
).property('sections')