Skip to content

Instantly share code, notes, and snippets.

View franciskim's full-sized avatar
🎯
Focusing

Francis Kim franciskim

🎯
Focusing
View GitHub Profile
function _process(value) {
return new Promise(function (fulfill, reject) {
var count = 0, timeout;
timeout = setInterval(function () {
console.log('iteration ' + count);
if (count > 5 && value !== 'fail') { fulfill(true); clearInterval(timeout); }
else if (count > 5 && value === 'fail') { reject('Operation timed out.'); clearInterval(timeout); }
count += 1;
}, 100);
});
@JacobHsu
JacobHsu / phantomjs_facebook.js
Created January 7, 2016 05:31
Log into Facebook with phantomJS
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.open("https://www.facebook.com", function(status) {
if ( status === "success" ) {
page.evaluate(function() {
*.log
*.sql
.DS_Store
.htaccess
*.map
error_log
Movefile
wp-cli.yml
sitemap.xml
sitemap.xml.gz
@oloynet
oloynet / resourcetiming.js
Created February 8, 2013 16:20
Catch all the resource load times with casperjs
var casper = require("casper").create({
//loadImages: false,
//logLevel: 'debug',
verbose: true
});
var utils = require('utils');
/* ----- test parameters ----- */
@mrluanma
mrluanma / user_agent_casper.js
Created December 14, 2012 17:16
How to set custom UserAgent in CasperJS.
var casper = require('casper').create({
verbose: true,
logLevel: "info",
pageSettings: {
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"
}
});
casper.start("https://httpbin.org/user-agent", function() {
this.test.assertTextExists(
@silvae86
silvae86 / gist:bc2aef529b0cc7da827aee05225c9f26
Created November 13, 2017 17:26
Solving Spawn ENOMEM Error in Ubuntu + NodeJS
#credits https://stackoverflow.com/questions/26193654/node-js-catch-enomem-error-thrown-after-spawn
sudo fallocate -l 4G /swapfile #Create a 4 gigabyte swapfile
sudo chmod 600 /swapfile #Secure the swapfile by restricting access to root
sudo mkswap /swapfile #Mark the file as a swap space
sudo swapon /swapfile #Enable the swap
echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab #Persist swapfile over reboots (thanks for the tip, bman!)
@ganglio
ganglio / fb.js
Created December 13, 2012 14:39
CasperJS: Facebook photos scraper
var casper = require('casper').create({
verbose : true,
logLevel : 'info'
});
var images = [];
var fs=require("fs")
/**
* Configuration here
*/
@erickpatrick
erickpatrick / php-7-3-install-magento-ngnix.sh
Last active April 30, 2020 01:16
Install php7.3-magento-ngnix
PATH_TO_MAGENTO='/path/to/magento/installation/folder'
GITHUB_TOKEN='github-token-here'
MAGENTO_USER='your-key-here'
MAGENTO_PASS='your-pass-here'
MAGENTO_ADMIN_URL='http://your-server.com'
MAGENTO_ADMIN_USER='admin'
MAGENTO_ADMIN_PASS='admin123'
# ondrej best php apt-repository for php to be able to
# update and install PHP as needed
@jonathonbyrdziak
jonathonbyrdziak / magento.conf
Last active June 18, 2020 17:55
A configuration file for magento under nginx.
#####################################################
#
# Provided by the Magento Support Center
# http://magentosupport.help/knowledgebase/configuring-nginx-to-work-with-magento-advanced/
#
# Your Magento Tutorial specialists
#
server {
listen *:8080;
server_name fanatik.redrokk.com www.fanatikbike.com fanatikbike.com;
@iaincollins
iaincollins / Google Spreadsheet.js
Last active May 30, 2021 16:03
Example Node.js code to append to a Google Spreadsheet every hour
/**
* Append data to a Google Spreadsheet
*
* You will need a file called '.env' with the following values:
*
* - GOOGLE_ID (Google oAuth Client ID)
* - GOOGLE_SECRET (Google oAuth Client Secret)
* - GOOGLE_REFRESH_TOKEN (Google oAuth Refresh Token)
* - GOOGLE_SPREADSHEET_ID (Google Spreadsheet ID)
*