Skip to content

Instantly share code, notes, and snippets.

View reyesyang's full-sized avatar

Yang Hailong reyesyang

View GitHub Profile
@ktsaou
ktsaou / autoscaled.sh
Created September 10, 2017 22:06
autoscale X/Wayland applications based on current DPI settings
#!/usr/bin/env bash
program="${1}"
append=
# -----------------------------------------------------------------------------
# HiDPI decision
primary_found="no"
@oelmekki
oelmekki / doc.md
Created December 30, 2015 19:37
Rails + Browserify + React + es7

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

@wvengen
wvengen / README.md
Last active March 25, 2024 07:53
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the

@ymjing
ymjing / Monaco for Powerline.md
Last active March 24, 2022 14:34
Powerline-patched Monaco for Windows and OSX

Powerline-patched Monaco for Windows and OSX

This font is manually patched with Fontforge. It includes the glyphs from DejaVu Sans Mono for Powerline.

I recommend DirectWrite-patched VIM builds. I'm using KaoriYa's build (http://www.kaoriya.net/software/vim/)

Usage

Add the following lines to your .vimrc/_vimrc:

# config/initializers/instrumentation.rb
# Subscribe to grape request and log with Rails.logger
ActiveSupport::Notifications.subscribe('grape.request') do |name, starts, ends, notification_id, payload|
Rails.logger.info '[API] %s %s (%.3f ms) -> %s %s%s' % [
payload[:request_method],
payload[:request_path],
(ends-starts)*1000,
(payload[:response_status] || "error"),
payload[:x_organization] ? "| X-Org: #{payload[:x_organization]}" : "",
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@thebucknerlife
thebucknerlife / authentication_with_bcrypt_in_rails_4.md
Last active January 17, 2024 23:54
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@codingfoo
codingfoo / deploy.rb
Created March 11, 2014 20:15
Rails 4 Capistrano 2 local assets precompile
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :app, :except => { :no_release => true } do
system("bundle check"); exit if $? != 0
system("RAILS_ENV=#{stage} bundle exec rake assets:precompile"); exit if $? != 0
servers = find_servers :roles => :web, :except => { :no_release => true }
run <<-CMD.compact
cp -- #{shared_manifest_path.shellescape} #{current_path.to_s.shellescape}/assets_manifest#{File.extname(shared_manifest_path)}
CMD
@hwdsl2
hwdsl2 / .MOVED.md
Last active May 4, 2024 03:19
IPsec VPN Server Auto Setup Script for Ubuntu and Debian
@yannleretaille
yannleretaille / validate-selectize-fields.js
Last active April 25, 2022 13:25
How to validate selectize.js comboboxes with the jQuery validation plugin
//How to validate selectize.js comboboxes with the jQuery validation plugin
//selectize.js: http://brianreavis.github.io/selectize.js/ (brianreavis/selectize.js)
//http://jqueryvalidation.org (jzaefferer/jquery-validation)
//configure jquery validation
$("#commentForm").validate({
//the default ignore selector is ':hidden', the following selectors restore the default behaviour when using selectize.js
//:hidden:not([class~=selectized]) | selects all hidden elements, but not the original selects/inputs hidden by selectize
//:hidden > .selectized | to restore the behaviour of the default selector, the original selects/inputs are only validated if their parent is visible
//.selectize-control .selectize-input input | this rule is not really necessary, but ensures that the temporary inputs created by selectize on the fly are never validated