Skip to content

Instantly share code, notes, and snippets.

View aghyad's full-sized avatar
🤖
Never give up

Aghyad Saleh aghyad

🤖
Never give up
View GitHub Profile

The following module can be placed in the root level of elixir-lang/elixir and executed using the following:

bin/elixirc keyword_delete_bench.ex && erl -noshell -pa . -pa lib/elixir/ebin -s 'keyword_delete_bench'

Example (minimized output):

## count=100000, size=10
@aghyad
aghyad / gdb_ruby_backtrace.py
Created June 20, 2016 16:21 — forked from csfrancis/gdb_ruby_backtrace.py
Dump an MRI call stack from gdb
string_t = None
def get_rstring(addr):
s = addr.cast(string_t.pointer())
if s['basic']['flags'] & (1 << 13):
return s['as']['heap']['ptr'].string()
else:
return s['as']['ary'].string()
def get_lineno(iseq, pos):
@chrissimpkins
chrissimpkins / gist:5bf5686bae86b8129bee
Last active March 6, 2023 00:10
Atom Editor Cheat Sheet: macOS

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on macOS.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key
@aghyad
aghyad / core_exts.rb
Last active August 29, 2015 14:11 — forked from shell/core_exts.rb
## Like a Symbol#to_proc but for array
class Array
def to_proc
lambda {|object|
self.map{|symbol| object.send(symbol.to_sym)}
}
end
end
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@csfrancis
csfrancis / gdb_ruby_backtrace.py
Last active April 24, 2024 05:37
Dump an MRI call stack from gdb
# Updated for Ruby 2.3
string_t = None
def get_rstring(addr):
s = addr.cast(string_t.pointer())
if s['basic']['flags'] & (1 << 13):
return s['as']['heap']['ptr'].string()
else:
return s['as']['ary'].string()
set -g prefix C-a # Make C-a the prefix instead of default
bind C-a send-prefix # Send to application
unbind C-b # Unbind C-b
set -sg escape-time 1 # Remove delay for keystrokes
setw -g mode-keys vi # Use vi mode
### Mouse mode ###
setw -g mode-mouse on # Toggle mouse mode globally
set -g mouse-select-pane on # Select pane using mouse

Security is Hard

Massive Assignment

  • watch for ActiveRecord Relation, like has_many, has_many :through
  • watch for user_roles, `group_users
  • UPDATE action

Admin

@tknazn
tknazn / registrations_controller.rb
Created September 22, 2012 07:45 — forked from evanbeard/registrations_controller.rb
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 1, 2024 03:34
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname