Skip to content

Instantly share code, notes, and snippets.

View rogerluan's full-sized avatar
🚀

Roger Oba rogerluan

🚀
View GitHub Profile
@juno
juno / README.md
Created November 1, 2011 08:40
Install rbenv and ruby-build to Amazon Linux (cloud-init).

Install rbenv and ruby-build to Amazon Linux (cloud-init).

  1. Copy & paste content of user-data.sh to EC2 RunInstances user-data
  2. Then, logging in to EC2 instance as ec2-user and run install-ruby.sh.
@remi
remi / .gitconfig
Created March 20, 2012 19:20
Find the most used verbs in your Git commit messages
[alias]
verbs = !git log --pretty=format:'%s' | cut -d \" \" -f 1 | sort | uniq -c | sort -nr
@akshay1188
akshay1188 / whatsapp-image-compression
Last active June 10, 2023 16:42
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
@felipecsl
felipecsl / restart coreaudio daemon
Last active April 24, 2024 18:39
Restart Mac OS X coreaudio daemon. Useful if you cannot change the audio output device to Airplay.
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'`
# or...
sudo killall coreaudiod
@jofi
jofi / ruby_files_in_load_paths.rb
Last active May 22, 2021 21:10
Quick tricks to expand load paths in ruby
# expand_path is genuine and DOES KNOW ABOUT absolute and relative paths
File.expand_path('relative/path/to/dir_or_file', '/start/path') # "/start/path/relative/path/to/dir_or_file"
File.expand_path('../application', __FILE__) # "/absolute/path/to/FILE/../application"
File.expand_path('/path/to/dir_or_file', '/start/path') # "/path/to/dir_or_file"
File.expand_path('../path/to/dir_or_file', '/start/path') # "/start/path/to/dir_or_file"
# join seems to be STUPID. It just joins strings (and adds file separator if needed)
File.join('some/path/', '/other/path.rb') # "some/path/other/path.rb"
# modify the global load path:
ACTION
AD_HOC_CODE_SIGNING_ALLOWED
ALTERNATE_GROUP
ALTERNATE_MODE
ALTERNATE_OWNER
ALWAYS_SEARCH_USER_PATHS
ALWAYS_USE_SEPARATE_HEADERMAPS
APPLE_INTERNAL_DEVELOPER_DIR
APPLE_INTERNAL_DIR
APPLE_INTERNAL_DOCUMENTATION_DIR
@nicklockwood
nicklockwood / gist:7446228
Last active December 28, 2015 04:59
Why having a single success/error callback block is better than having separate ones

Suppose you have a network method that only uses a single block callback

typedef void (^Handler)(BOOL success, id response, NSError *error);

- (void)makeRequestWithHandler:(Handler)handler;

But you have to make this request dozens of times, and you want to reuse the same failure handler in most cases? Easy, just have a factory function that returns a block:

typedef void (^SuccessHandler)(id response);

typedef void (^ErrorHandler)(NSError *error);

@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing
@nicolasembleton
nicolasembleton / restart_bluetooth.sh
Last active October 21, 2022 20:10
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport

progrium/bashstyle

Bash is the JavaScript of systems programming. Although in some cases it's better to use a systems language like C or Go, Bash is an ideal systems language for smaller POSIX-oriented or command line tasks. Here's three quick reasons why:

  • It's everywhere. Like JavaScript for the web, Bash is already there ready for systems programming.
  • It's neutral. Unlike Ruby, Python, JavaScript, or PHP, Bash offends equally across all communities. ;)
  • It's made to be glue. Write complex parts in C or Go (or whatever!), and glue them together with Bash.

This document is how I write Bash and how I'd like collaborators to write Bash with me in my open source projects. It's based on a lot of experience and time collecting best practices. Most of them come from these two articles, but here integrated, slightly modified, and focusing on the most bang for buck items. Plus some ne