Skip to content

Instantly share code, notes, and snippets.

View chaadow's full-sized avatar
🎯
Focusing

Chedli Bourguiba chaadow

🎯
Focusing
View GitHub Profile
#!/usr/bin/env ruby
require 'JSON'
class LocationGetter
attr_reader :endpoint
def initialize(endpoint)
@endpoint = endpoint
end
@nauzilus
nauzilus / stream_vs_array.js
Last active December 25, 2023 10:52
(Highland) stream vs array transformation
(function() {
var highland = require("highland")
var array = [1,2,3],
spy = (message, fn) => {
return x => {
console.log(`${message} ${x}`)
return fn(x)
}
},
class CategoriesController < ApplicationController
include Behaveable::ResourceFinder
include Behaveable::RouteExtractor
# Response type.
respond_to :json
# Get categories.
#
# GET (/:categorizable/:categorizable_id)/categories(.:format)
@alameenkhader
alameenkhader / rails-rpush.md
Last active August 28, 2020 09:10
Rpush/Rails Integration

###rpush - https://github.com/rpush/rpush

Follow the steps in rpush to add the gem to your rails project

####PushNotificationDevice

rails g model PushNotificationDevice device_type:integer:index device_token:string
class CreatePushNotificationDevices < ActiveRecord::Migration
@brianstorti
brianstorti / priority_queue.rb
Last active November 17, 2022 16:14
Priority queue implementation in Ruby
class PriorityQueue
attr_reader :elements
def initialize
@elements = [nil]
end
def <<(element)
@elements << element
bubble_up(@elements.size - 1)
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@staltz
staltz / introrx.md
Last active June 13, 2024 19:58
The introduction to Reactive Programming you've been missing
@dvliman
dvliman / gist:10402435
Created April 10, 2014 17:02
ruby $ global variable
$: (Dollar Colon) is basically a shorthand version of $LOAD_PATH. $: contains an array of paths that your script will search through when using require.
$0 (Dollar Zero) contains the name of the ruby program being run. This is typically the script name.
$* (Dollar Splat) is basically shorthand for ARGV. $* contains the command line arguments that were passed to the script.
$? (Dollar Question Mark) returns the exit status of the last child process to finish.
$$ (Dollar Dollar) returns the process number of the program currently being ran.
$~ (Dollar Tilde) contains the MatchData from the previous successful pattern match.
$1, $2, $3, $4 etc represent the content of the previous successful pattern match.
$& (Dollar Ampersand) contains the matched string from the previous successful pattern match.
$+ (Dollar Plus) contains the last match from the previous successful pattern match.
$` (Dollar Backtick) contains the string before the actual matched string of the previous successful pattern match.
@wrought
wrought / wordlists.html
Created October 21, 2013 22:02
Links to some word lists
<a name="resources">Resources used in compiling this wordlist</a></h2><a name="resources">
</a><ul><a name="resources">
</a><li><a name="resources"></a><a href="http://www.dcs.shef.ac.uk/research/ilash/Moby/">The Moby lexicon project</a> / Grady Ward <p>
</p></li><li><a href="http://ftp.digital.com/pub/misc/stolfi-wordlists/">The stolfi wordlists</a> / Jorge Stolfi and the original wordlist authors<br>
The wordlists in different languages were very useful in finding international words by intersection.<p>
</p></li><li><a href="ftp://ftp.ox.ac.uk/pub/wordlists">The wordlist collection at Oxford</a> / administered by Paul Leyland <p>
@rafaelfranca
rafaelfranca / deprecation.rb
Last active March 12, 2024 14:33
Examples of `ActiveSupport::Deprecation`
require 'active_support'
class Foo
def foo
"foo"
end
def bar
ActiveSupport::Deprecation.warn("bar is deprecated")