Skip to content

Instantly share code, notes, and snippets.

View chaadow's full-sized avatar
🎯
Focusing

Chedli Bourguiba chaadow

🎯
Focusing
View GitHub Profile
@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 May 2, 2024 12:31
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")
@Burgestrand
Burgestrand / retry.rb
Created April 3, 2013 10:55
Retry a block a given number of times if necessary, protecting against a whitelist of exceptions
class Fixnum
# Runs a block, catching any exceptions matching the exceptions in the
# input parameters. After +self+ number of tries, the exception is
# re-raised and the attempts will terminate.
#
# @yield +self+
# @param [Exception, …] exs Exceptions that will be caught and recovered from.
# @return Whatever the block returns.
def tries(*exs)
exs = [StandardError] if exs.empty?
@Huluk
Huluk / gist:5117702
Last active December 8, 2023 22:34
Open Files with Terminal Vim by default [mac, iterm]
If you want your terminal vim to open files you double click, follow the following steps (MacOS only):
1. Open Automator
2. Select Application
3. Copy the attached file
4. Save and set as default for opening files
Multiple files are opened in vim tabs.
If there is already a vim instance running, files are opened in it.
@olivierlacan
olivierlacan / gist:4062929
Last active February 10, 2024 10:57 — forked from Gregg/gist:968534
Code School Screencasting Framework

Screencasting Framework

The following document is a written account of the Code School screencasting framework. It should be used as a reference of the accompanying screencast on the topic.

Why you should care about screencasting?

You're probably aren't going to take the time to read this document if you're not interested, but there are a lot of nice side effects caused by learning how to create quality screencasts.

  1. Communicating more effectively - At Envy Labs we produce screencasts for our clients all the time. Whether it's demoing a new feature or for a presentation for an invester, they're often much more effective and pleasent than a phone call or screen sharing.