Skip to content

Instantly share code, notes, and snippets.

View chunlea's full-sized avatar
👨‍💻
Working from home

chunli chunlea

👨‍💻
Working from home
View GitHub Profile
@chunlea
chunlea / Gemfile
Created June 25, 2020 02:05 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@chunlea
chunlea / gist:41646d3a28181e5405d37dfc570ddb6b
Created January 31, 2019 16:07 — forked from mprymek/gist:8379066
Elixir metaprogramming example
# This is an example of metaprogramming in the Elixir language.
#
# We will define a domain specific language (DSL) for the definition
# of a service which is watched by several sensors.
# Each sensor watches some property/functionality of the service and
# returns the result of the check.
#
# To determine if the service is functioning properly, we need functions
# to run all the sensors' code and gather the returned data.
#
#!/usr/bin/sudo sh
## ruby_revealer.sh -- decrypt obfuscated GHE .rb files. 2.0.0 to 2.3.1+.
## From `strings ruby_concealer.so`:
##
## > This obfuscation is intended to discourage GitHub Enterprise customers
## > from making modifications to the VM.
##
## Well, good, as long as its not intended to discourage *me* from doing this!
@chunlea
chunlea / Deploy.cs
Created July 10, 2016 06:19 — forked from FrayxRulez/Deploy.cs
Deploy UWP apps to Windows 10 Mobile
// Initializes MultiTargetingConnectivity with current PC culture
var connectivity = new MultiTargetingConnectivity(Thread.CurrentThread.CurrentUICulture.LCID);
var devices = connectivity.GetConnectableDevices();
// Gets the first physical device attached to PC.
// WARNING: if more than a single device is connected to the PC deploy will fail.
var phone = devices.FirstOrDefault(x => !x.IsEmulator());
// PhoneProductId of the app, you can find it in your Package.appxmanifest
var package = Guid.Parse("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");

Using Obj-C with MacRuby/Rubymotion

This little post aims to help you to translate Objective-C Blocks into Ruby blocks. Let's start by taking a look at few examples of iOS API call where blocks are used for animations and enumeration

Ruby Lambda Syntaxes:

Im Rubymotion and MacRuby you can use all the Ruby Lambda syntaxes that are:

block = lambda { |param|  ... }
@chunlea
chunlea / Locales.yaml
Last active August 29, 2015 14:10 — forked from wojtha/Locales.yaml
# config/locales/en.yml
en:
exception:
show:
not_found:
title: "Not Found"
description: "The page you were looking for does not exists."
internal_server_error:
title: "Internal Server Error"
upstream myapp_puma {
server unix:/tmp/myapp_puma.sock fail_timeout=0;
}
# for redirecting to https version of the site
server {
listen 80;
rewrite ^(.*) https://$host$1 permanent;
}

Using Obj-C with MacRuby/Rubymotion

This little post aims to help you to translate Objective-C Blocks into Ruby blocks. Let's start by taking a look at few examples of iOS API call where blocks are used for animations and enumeration

Ruby Lambda Syntaxes:

Im Rubymotion and MacRuby you can use all the Ruby Lambda syntaxes that are:

block = lambda { |param|  ... }
module ProMotion
module Table
module LoadmoreClassMethods
def load_moreable=(val)
@load_moreable = val
end
def load_moreable
@load_moreable || false
end
def load_more_options=(val)
# http://stackoverflow.com/questions/14972253/simpleform-default-input-class
# https://github.com/plataformatec/simple_form/issues/316
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput