Skip to content

Instantly share code, notes, and snippets.

View sas1ni69's full-sized avatar

Hassanin Ahmed sas1ni69

View GitHub Profile
def format_name(format: "%{first_name} %{last_name}, (%{preferred_name})", **names)
defaults = { first_name: '', last_name: '', preferred_name: '' }
names = defaults.merge(names.slice(:first_name, :last_name, :preferred_name))
(format % names).squish
end
package main
import (
"reflect"
"testing"
)
func BenchmarkBubbleSortWrostCase(b *testing.B) {
for n := 0; n < b.N; n++ {
unsortedArray := []int{97, 96, 95, 93, 93, 92,
package main
func BubbleSort(array []int) []int {
if len(array) <= 1 {
return array
}
for i := 0; i <= len(array)-1; i++ {
for j := len(array) - 1; j > i; j-- {
if array[j] < array[j-1] {

Keybase proof

I hereby claim:

  • I am sas1ni69 on github.
  • I am hass (https://keybase.io/hass) on keybase.
  • I have a public key ASDI0TlPx_Kt83WkFRhxg_DfanWBDIknSV6UzVReNo5Scgo

To claim this, I am signing this object:

@sas1ni69
sas1ni69 / monetize_jsonb.rb
Last active July 6, 2017 23:59
Extending the monetize gem to use jsonb attributes. (Currency not included)
module MonetizeJsonb
def monetize_jsonb(*attrs)
attrs.each do |attr_name|
define_method("#{attr_name}=") do |value|
value_in_cents = Monetize.parse(value, account.currency).cents
self.send("#{attr_name}_cents=", value_in_cents)
end
define_method(attr_name) do
Money.new(self.send("#{attr_name}_cents"), account.currency)
@sas1ni69
sas1ni69 / color.txt
Created March 20, 2016 04:27
Color Hex and Names
4C4F56 Abbey
1B1404 Acadia
7CB0A1 Acapulco
C9FFE5 Aero Blue
714693 Affair
D4C4A8 Akaroa
FAFAFA Alabaster
F5E9D3 Albescent White
93DFB8 Algae Green
F0F8FF Alice Blue
@sas1ni69
sas1ni69 / resize_images.bash
Created March 16, 2016 07:44
Resize all images in dir
for p in *;do
(cd $p && sips -Z 600 *.jpg)
done
@sas1ni69
sas1ni69 / 0_reuse_code.js
Last active August 29, 2015 14:24
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
ag
ctrlp.vim
emmet-vim
nerdtree
powerline-fonts
vim-airline
vim-bundler
vim-coffee-script
vim-commentary
vim-fugitive