Skip to content

Instantly share code, notes, and snippets.

@mohamedmansour
mohamedmansour / click.js
Created July 16, 2011 01:09
Simulate a click in JavaScript for Google+ Share
function simulateClick(element) {
var clickEvent = document.createEvent("MouseEvents")
clickEvent.initEvent("mousedown", true, true)
element.dispatchEvent(clickEvent);
clickEvent = document.createEvent("MouseEvents")
clickEvent.initEvent("click", true, true)
element.dispatchEvent(clickEvent);
clickEvent = document.createEvent("MouseEvents")
@jaydson
jaydson / gist:1780598
Created February 9, 2012 15:11
How to detect a click event on a cross domain iframe
var myConfObj = {
iframeMouseOver : false
}
window.addEventListener('blur',function(){
if(myConfObj.iframeMouseOver){
console.log('Wow! Iframe Click!');
}
});
document.getElementById('YOUR_CONTAINER_ID').addEventListener('mouseover',function(){
@addyosmani
addyosmani / headless.md
Last active May 17, 2024 03:38
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 https://developers.google.com/web/updates/2017/04/headless-chrome.

Update

If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md

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

@miguelmota
miguelmota / default
Last active January 30, 2023 02:28
Nginx + Node.js server configuration. Blog post: http://www.miguelmota.com/blog/nodejs-and-ngnix-on-ubuntu/
# The upstream module is the link between Node.js and Nginx.
# Upstream is used for proxying requests to other servers.
# All requests for / get distributed between any of the servers listed.
upstream helloworld {
# Set up multiple Node.js webservers for load balancing.
# max_fails refers to number of failed attempts
# before server is considered inactive.
# weight priorities traffic to server. Ex. weight=2 will recieve
# twice as much traffic as server with weight=1
server <your server ip>:3000 max_fails=0 fail_timeout=10s weight=1;
@DinisCruz
DinisCruz / 87-prettify-url-on-pop-under-window.js
Last active May 6, 2023 00:09
Misc Chrome extensions code snippets (to add to helper doc)
url = 'http://127.0.0.1:4444/wd/hub/sessions'
options = { active:true, windowType:"normal", currentWindow: true }
chrome.tabs.query(options,function(tabs)
{
tabId = tabs[0].id
console.log(tabId)
chrome.tabs.update(tabId, {url: url})
chrome.tabs.executeScript(tabId, {file:'bower_components/jquery/dist/jquery.min.js'}, function()
@Bodom78
Bodom78 / whm-change-document-root.md
Last active May 13, 2024 15:54
WHM/cPanel - Changing an accounts document root

To properly edit an accounts DocumentRoot go to /var/cpanel/userdata/username/ (replace username with the actual cPanel username for the account), then edit the file domain.com (where domain.com is your primary domain name).

You will see something like this in that file:

documentroot: /home/username/public_html

You will also see the cgi-bin area in this section:

scriptalias:

First of all, this is not my brilliant effort to get react-native working on Windows, it is the collation of work by others, particularly @mqli and @Bernd Wessels. I've just summarised what worked for me.

If you would prefer to read what I've plagerised, head over to mqli's great gist

Disclaimer

  • The below is tested with react-native-cli 0.1.5, react-native 0.12.0 on Windows 10, node 4.1.1, and Android (physical Nexus 6 and AVD with API v22)
  • I hope this will all be redundant in a few weeks. Please comment on stuff that is now fixed and I will update this to keep it relevant.
  • Sprinkle a bit of YMMV around

Keep this github issue handy, it’s the bucket for all Windows/Linux related tricks to get RN working.

@jtrefry
jtrefry / Win10-64bit-npm.md
Last active September 6, 2023 07:30
Configuring Windows 10 (64-bit) for npm and node-gyp
  • Install Git for Windows
  • Install Node
  • Install Python 2.7.3
  • Install Microsoft Visual Studio 2015 Community
  • Open the command prompt as Administrator, run the following commands, then close the command prompt (a new prompt is required before the new environment variables will be available)
    • npm install -g npm
      • (Upgrades to npm v3, which no longer nests dependencies indefinitely. No more "maximum path length exceeded" errors due to the 260 character path limit in Windows, or needing to delete node_modules with rimraf.)
    • setx PYTHON C:\Python27\python.exe /m
      • (May need to change path to your custom install directory.)
  • Open a new command prompt and run the following commands. If these install without errors, you have bypasse
@clemlatz
clemlatz / nginx-config.conf
Last active December 23, 2022 10:43
Set up ssl proxy with nginx and letsencrypt (https://secure.example.com => http://example.com)
# SSL server config
server {
listen 443 ssl;
server_name secure.example.com;
ssl_certificate /etc/letsencrypt/live/secure.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/secure.example.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
@MattRix
MattRix / ObjExporter.cs
Last active June 21, 2024 06:31
Exports Unity meshes to an obj file
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
using System.Text;
public class ObjExporterScript
{
private static int StartIndex = 0;