Skip to content

Instantly share code, notes, and snippets.


Chamnap Chhorn chamnap

View GitHub Profile
ipepe /
Last active May 23, 2021
Installing headless chrome on Ubuntu.
# from
# and
# and
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:canonical-chromium-builds/stage
sudo apt-get update
sudo apt-get install chromium-browser
chromium-browser --headless --no-sandbox
anlek / application.scss
Last active Apr 30, 2020
My current work around for simple_form and Bootstrap 4 beta to work together (till simple_form allows input fields to have `is-invalid` set on it on error - see
View application.scss
// Fix for validations on simple form
// Need to import bootstrap functions and mixins if you want to dynamically set colors
// Otherwise replace theme-color... with hex color
@import 'bootstrap/functions';
@import 'bootstrap/variables';
@import 'bootstrap/mixins';
.has-invalid {
.invalid-feedback {
johanndt /
Last active Jul 6, 2020 — forked from dideler/
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu


Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
carlesso / phantomtumblr.js
Last active Mar 15, 2016
Phantom Tumblr https error
View phantomtumblr.js
var page = require('webpage').create();
var system = require('system');
page.onResourceRequested = function (request) {
system.stderr.writeLine('= onResourceRequested()');
system.stderr.writeLine(' request: ' + JSON.stringify(request, undefined, 4));
page.onResourceReceived = function(response) {
system.stderr.writeLine('= onResourceReceived()' );
henrik / month.rb
Last active Jan 12, 2018
Ruby Month class.
View month.rb
require "attr_extras" # gem
class Month
vattr_initialize :year, :month_number
def self.from(object)
case object
when Month then object
else new(object.year, object.month)
julionc /
Last active May 28, 2021
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
View mongoid_observers.rb
module MyObservers
module Document
module ClassMethods
def observers= (*observers)
def declared_observers
@declared_observers ||= []
FokkeZB /
Created Sep 20, 2013
URL schemes for iOS and Android (2/2)
njakobsen / live_database_dump.rb
Last active Oct 12, 2019
Live stream a database dump (or any other STDOUT) using Rails 4. Why would you want this? If you have a large database dump and want to avoid storing it in memory as Rails streams it. This allows pipe the dump directly into the http response instead of storing it as a file, sending it, and then deleting it. Let me know what you think! I've teste…
View live_database_dump.rb
class DatabaseController < ApplicationController
def database_dump
database = Rails.configuration.database_configuration[Rails.env]["database"]
send_file_headers!(:type => 'application/octet-stream', :filename => "#{database}_#{}.backup")
pipe = IO.popen("pg_dump '#{database}' -F c")
stream =
while (line = pipe.gets)
stream.write line
sleep 0.0001 # HACK: Prevent server instance from sleeping forever if client disconnects during download
addyosmani /
Last active Jun 4, 2021
So, you want to run Chrome headless.

Update May 2017

Eric Bidelman has documented some of the common workflows possible with headless Chrome over in


If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome:

Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.