Skip to content

Instantly share code, notes, and snippets.

View jookyboi's full-sized avatar

Rui Jiang jookyboi

View GitHub Profile
@jookyboi
jookyboi / random_boolean.rb
Created November 19, 2013 21:19
Randomly pick boolean value
[true, false].sample
@jookyboi
jookyboi / fix.md
Last active March 22, 2018 18:56
The following is a hack to get around the issue posed by https://github.com/paypal/paypal-checkout/issues/323. It uses Electron to close the BrowserWindow when the popup fails to load. In the latest version of `checkout.js`, Paypal will fall back to

From Electron's main.ts:

import { BrowserWindow, ipcMain } from 'electron';
...
ipcMain.on(
    'close-paypal',
    () => {
        BrowserWindow.getAllWindows().forEach((win) => {
            // The Paypal window would fail to load contents due to security 
 // restrictions and return an empty URL
// PhantomJS Cheatsheet
$ brew update && brew install phantomjs // install PhantomJS with brew
phantom.exit();
var page = require('webpage').create();
page.open('http://example.com', function() {});
page.evaluate(function() { return document.title; });
$(document).bind("contextmenu", function(event) {
event.preventDefault();
$("<div class='custom-menu'>Custom menu</div>")
.appendTo("body")
.css({top: event.pageY + "px", left: event.pageX + "px"});
});
@jookyboi
jookyboi / capitalize_first_letter.js
Last active October 23, 2017 20:32
Capitalize first letter of event
function capitaliseFirstLetter(string)
{
return string.charAt(0).toUpperCase() + string.slice(1);
}
RSpec.configure do |config|
Capybara.javascript_driver = :webkit
end
page.find('#element').trigger(:mouseover)
@jookyboi
jookyboi / delete_branch.sh
Last active September 21, 2017 19:15
Delete a Git branch remotely.
g push origin --delete [branch_name]
@jookyboi
jookyboi / wait ajax.js
Created October 11, 2013 15:28
Execute a function when both ajax requests are complete. From http://api.jquery.com/jQuery.when/
$.when( $.ajax( "/page1.php" ), $.ajax( "/page2.php" ) ).done(
function( a1, a2 ) {
// do something
});
What’s stopping your web pages from getting silky smooth scrolling, buttery animation and a user experience that’s snappy and fast? Jank-free rendering performance has been shown to positively affect user engagement and experience in many large sites, but remains an area many are unaware of how to diagnose or optimize.
To highlight how widespread rendering is a performance bottleneck, I’ve been giving a few talks walking through a detailed case study of the Pinterest.com feed. A recording of the most recent one is now up where you might learn about common paint issues in modern sites and equally as importantly — how to diagnose them.
By the end of the recording you’ll be equipped with the knowledge to use a number of performance diagnosis features in Chrome DevTools to find and fix rendering issues in your own sites.