Skip to content

Instantly share code, notes, and snippets.

Avatar
🤗
hello wrold

Freeman nabilfreeman

🤗
hello wrold
View GitHub Profile
@nabilfreeman
nabilfreeman / gist:bd0d413993ddfc964c18
Created Oct 7, 2014
instanceof Element returns false
View gist:bd0d413993ddfc964c18
I had a problem with a site my widget was embedded on.
var el = document.createElement("div");
el instanceof Element;
>>> false
wat...
every other site on the planet returned true.
It turns out the culprit was Mootools v1.11.
@nabilfreeman
nabilfreeman / gist:7e82aa5ac4ef172d22c5
Created May 20, 2015
SOLVED: discoveryd eating up battery and CPU on Mac OS X Yosemite 10.10.3
View gist:7e82aa5ac4ef172d22c5
discoveryd is completely fucked in some way in Yosemite. It randomly starts using up 100% CPU and doesn't stop until you reboot or the laptop dies.
To fix the CPU/battery rape, you need to restart the service with these shell commands:
launchctl unload -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
No sudo required. The problem will randomly return after restarting the service, so I configured launchd to run a shell script with those commands in it every hour.
No more problems, and it appears to have caused no side effects.
View gist:ae3a64d3bbddf4974b5d
// AWS settings
public static function AWS_ACCESS_KEY_ID(){
if(isset($_SERVER['AWS_ACCESS_KEY_ID'])){
return $_SERVER['AWS_ACCESS_KEY_ID'];
} else {
return "XXX";
}
}
public static function AWS_SECRET_KEY(){
if(isset($_SERVER['AWS_SECRET_KEY'])){
@nabilfreeman
nabilfreeman / lambda-deploy.sh
Created Aug 22, 2016
AWS Lambda deploy script for Node.js
View lambda-deploy.sh
# AWS Lambda Node.js deploy script
# @author Nabil Freeman <nabil@instafork.com> (https://github.com/nabilfreeman)
# ***************************************
# Environment variables required:
# AWS_ACCESS_KEY_ID=XXXXXXX
# AWS_SECRET_ACCESS_KEY=XXXXXXXX
# AWS_DEFAULT_REGION=eu-west-1
# LAMBDA_FUNCTION_NAME=asdfghjkl
@nabilfreeman
nabilfreeman / restart-codeship-lambda.js
Last active Nov 9, 2017
Restart Codeship build from AWS Lambda
View restart-codeship-lambda.js
const https = require('https');
const { CODESHIP_KEY, PROJECT_ID } = process.env;
const getBuilds = () => {
console.time('Fetching builds...');
return new Promise((resolve, reject) => {
const host = 'codeship.com';
const path = `/api/v1/projects/${PROJECT_ID}.json?api_key=${CODESHIP_KEY}`;
const options = {
@nabilfreeman
nabilfreeman / copyToFat32.sh
Created Nov 8, 2018
FAT32 File copier & splitter (works with Multiman)
View copyToFat32.sh
#!/bin/bash
# Are you using Mac OS X?
# You probably need to install a newer version of split for this to work.
# try `brew install coreutils`
# or `sudo port install coreutils`
# set a part size that works with FAT32 drives
PART_SIZE=3999
# nice little intro
@nabilfreeman
nabilfreeman / copyToFat32.sh
Created Nov 8, 2018
FAT32 File copier & splitter (works with Multiman)
View copyToFat32.sh
#!/bin/bash
# Are you using Mac OS X?
# You probably need to install a newer version of split for this to work.
# try `brew install coreutils`
# or `sudo port install coreutils`
# set a part size that works with FAT32 drives
PART_SIZE=3999
# nice little intro
@nabilfreeman
nabilfreeman / pizzly.js
Last active Jun 29, 2020
Pizzly Node.js integration using Axios and environment variables (2 examples: Xero and Trello)
View pizzly.js
const Axios = require('axios');
const {
PIZZLY_URL,
PIZZLY_SECRET_KEY,
PIZZLY_TRELLO_ID,
PIZZLY_XERO_ID,
} = process.env;
const integrations = {
@nabilfreeman
nabilfreeman / gist:d4af1b7be7291baec5be44aae69806d4
Last active Nov 9, 2020
How to delete things from /usr/bin
View gist:d4af1b7be7291baec5be44aae69806d4
# In macOS Catalina onwards `/usr/bin` is protected. Before you would only need to run a root shell to make any changes. Now there is something extra to do.
# Let's say I want to run this command:
# sudo rm -rf /usr/bin/python3
# Deleting something will give you the error:
# rm: /usr/bin/python3: Read-only file system
# To get around this you need to first run:
@nabilfreeman
nabilfreeman / ccdl.command
Created Feb 15, 2021 — forked from ayyybe/ccdl.command
Adobe Offline Package Generator v0.1.2 (macOS only)
View ccdl.command
#!/bin/bash
CYAN="$(tput bold; tput setaf 6)"
RESET="$(tput sgr0)"
clear
if command -v python3 > /dev/null 2>&1; then
if [ $(python3 -c "print('ye')") = "ye" ]; then
clear