Skip to content

Instantly share code, notes, and snippets.

View plbabin's full-sized avatar

Pierre-Luc Babin plbabin

View GitHub Profile
@ungoldman
ungoldman / dokku_setup.md
Last active November 28, 2023 12:35
Deploy your own PaaS: Setting up Dokku with DigitalOcean and Namecheap

Deploy your own PaaS!

Setting up Dokku with DigitalOcean and Namecheap

..or how I made my own heroku in a few hours for $3.98.


This write-up is several years out of date! You probably shouldn't use it.

@stefanvermaas
stefanvermaas / app_delegate.rb
Last active March 31, 2016 00:54
To synchronize data between a RubyMotion app and a Rails API I needed a sort of a synchronization helper. This code is a proof of concept for this synchronization helper. It uses RubyMotion and BubbleWrap.
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
# For unit testing the application
return true if RUBYMOTION_ENV == 'test'
# Get the frame for the window
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
# Load all the data from the API
class EventCell < UITableViewCell
IDENTIFIER = 'EventCell'
PADDING = 10
LEFT_MARGIN = 40
RIGHT_MARGIN = 20
attr_reader :event
def initWithStyle(style, reuseIdentifier: reuse_identifier)
super.tap do |cell|
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user!
before_filter :restrict_routes!
cattr_reader :restrictions
def self.allow(kls, *actions)
@@restrictions ||= Restrictions.new
self.restrictions.add self, kls, actions
@L-A
L-A / design-primer-for-devs.md
Last active December 19, 2015 00:19
[In French] A tiny list of references for developers who like design
@brentsimmons
brentsimmons / gist:5810992
Last active January 3, 2021 02:22
Detect a tap on a URL inside a UITextView. Note: the rs_links method isn't included -- you'll need something that takes text and returns an array of detected links. This gist just demonstrates walking through the UITextView characters.
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1)
return NO;
class MyCustomCell < UITableViewCell
# This method is used by ProMotion to instantiate cells.
def initWithStyle(style_name, reuseIdentifier: reuseIdentifier)
super
stylish
self
end
# A delegate method when the user clicks the Row(it's blue by default)
@EtienneLem
EtienneLem / application.erb
Last active December 17, 2015 06:59
Modular DOMReady example (Rails)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Modular DOMReady</title>
</head>
<body>
<header></header>
<section role="main">
class MyController < UIViewController
def viewDidLoad
@button = UIButton.alloc.init
@button.when_tapped do
weak_self = WeakRef.new(self) # <--- create a weak reference to self
@alert = UIAlertView.alertViewWithTitle "Alert",
message: "Message",
cancelButtonTitle: "Dismiss",
@adstage-david
adstage-david / 0_README.markdown
Last active February 7, 2018 16:20
Building an RFC compliant JSON-Patch with Rails 3 and Backbone

I recently got PATCH mostly working with Backbone and Rails 3, here's what I needed to do.

Sticking Points:

  1. [Rails] JSON Patch gem needs updated.
  2. [Rails] Routing verb for patch missing - I believe this is fixed in Rails 4, haven't investigated.
  3. [Rails] Need to parse the 'application/json-patch+json' content type in sort of a crazy way
  4. [Rails] Building a patch and applying it to an activerecord model is kind of a pain, ideally we'd have a ActiveModel#apply_patch(json_patch)
  5. [Backbone] Building a patch from a set of attributes is tricky - I've done the bare minimum using a loop over a hash to build add operations, which should probably cover a good chunk of cases for backbone. (I imagine most people aren't going to need the json-patch support for moving, copying or deleting keys generally.)