Skip to content

Instantly share code, notes, and snippets.

require 'base64'
class Provider < ActiveRecord::Base
belongs_to :user
def prepare_access_token(oauth_token, oauth_token_secret)
token_hash = { oauth_token: oauth_token, oauth_token_secret: oauth_token_secret }
access_token = OAuth::AccessToken.from_hash(TWITTER_APP, token_hash)
access_token
end
class Candidate < ActiveRecord::Base
include PgSearch
pg_search_scope :search_by_candidate,
against: {
enterprise: 'A',
last_name: 'B',
first_name: 'C'
},
using: {
tsearch: {
@jeanbaptistebeck
jeanbaptistebeck / 0_reuse_code.js
Created December 16, 2015 13:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jeanbaptistebeck
jeanbaptistebeck / serialization.rb
Last active January 20, 2016 11:14
Serialization
class User < ActiveRecord::Base
serialize :preferences, Hash
def initialize(preferences = {})
@preferences = preferences
end
end
user = User.create({ food: { tomatoes: true, salad: false }, sleep: { light: false, noise: false } })
require 'verbal_expressions'
tester = VerEx.new do
start_of_line
find 'http'
maybe 's'
find '://'
maybe 'www.'
anything_but ' '
end_of_line
@jeanbaptistebeck
jeanbaptistebeck / applescript.md
Last active February 3, 2016 09:54
Messing around with AppleScript

Playing with applications

tell application "Spotify"
  play track "spotify:track:51pQ7vY7WXzxskwloaeqyj"
end tell
tell application "Finder"
@jeanbaptistebeck
jeanbaptistebeck / zip.md
Last active February 10, 2016 10:32
Ruby's Zip Method

Ruby's Zip Method

[1,2,3].zip(['a', 'b', 'c'])
#=> [[1, "a"], [2, "b"], [3, "c"]]
['a', 'b', 'c'].zip( [1,2,3], ['oogie', 'boogie', 'booger'] )
#=&gt; [["a", 1, "oogie"], ["b", 2, "boogie"], ["c", 3, "booger"]]
@jeanbaptistebeck
jeanbaptistebeck / actioncable.md
Last active February 11, 2016 08:05
ActionCable & Websockets

ActionCable & WebSockets

Gif

Hey! Hey server! You got any new data? Server? SERVER!.

What are Websockets ?

WebSocket is a protocol providing full-duplex communication channels over a single TCP connection.

@jeanbaptistebeck
jeanbaptistebeck / blog.md
Last active February 15, 2016 11:18
Install BrandAndCelebrities blog

Installation process

  • Check that Apache is installed by running httpd -v in the terminal
  • Create the Site folder : mkdir ~/Sites
  • Find your username with whoami
  • Create the config file : sudo nano /etc/apache2/users/votreuser.conf
  • Paste the following code :
<Directory "/Users/votreuser/Sites/">
    Options Indexes MultiViews
    AllowOverride All
@jeanbaptistebeck
jeanbaptistebeck / observers.md
Last active February 16, 2016 18:03
Active Record Observer

Observers in Rails

gem 'rails-observers'

Life without observers

class Application < ActiveRecord::Base