Skip to content

Instantly share code, notes, and snippets.

@agibsonsw
agibsonsw / hide_element
Created February 5, 2012 16:35
JS Bookmarklet to hide an element on click
javascript:(function(){var%20d=document,useMine=true,prevEl;function%20AddHandler(orig,mine)
{return%20function(e){if(useMine)mine(e);else%20if(orig)orig(e);};}function%20Myonmouseover(e)
{var%20evt=e||window.event;var%20elem=evt.target||evt.srcElement;elem.style.outline='2px%20solid%20gray';
prevEl=elem;}function%20Myonmouseout(e){var%20evt=e||window.event;var%20elem=evt.target||evt.srcElement;elem.style.outline='';}
function%20Myonclick(e){var%20evt=e||window.event;var%20elem=evt.target||evt.srcElement;elem.style.display='none';}
function%20Myonkeydown(e){var%20evt=e||window.event;if(evt.keyCode==27){prevEl.style.outline='';useMine=false;}}
d.onmouseover=AddHandler(d.onmouseover,Myonmouseover);d.onmouseout=AddHandler(d.onmouseout,Myonmouseout);
d.onclick=AddHandler(d.onclick,Myonclick);d.onkeydown=AddHandler(d.onkeydown,Myonkeydown);})()
@aquaxp
aquaxp / macOS_Airport.md
Last active May 22, 2017 00:47
OS X Airport

macOS Airport

macOS WiFi Wireless Scanner

If you are looking for a basic WiFi scanner for macOS then the command line airport utility may fit your needs. The utility is located at: /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport

Typing the above command path can be avoided by creating a symbolic link to the command in /user/sbin/ by copying and pasting below into a terminal window.

`sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport`

This will allow you to simply type airport in the terminal window to execute the command.

@natelandau
natelandau / .bash_profile
Last active June 13, 2024 18:01
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
# =======================================
# OS X — ONE CLICK — EJECT ALL DISKS
# =======================================
# Open Script Editor on OS X
# Copy and paste this file in
# Pre-High Sierra: Save As > Application
# High Sierra: Export > File Format > Application
# Name it "Eject All Disks"
# Drag created application to Dock
# Now you can eject all external disks with one click from Dock
@sandeepmistry
sandeepmistry / BLEPeripheral_NeoPixel.ino
Created March 25, 2015 23:14
BLEPeripheral + NeoPixel
// Import libraries (BLEPeripheral depends on SPI)
#include <SPI.h>
#include <BLEPeripheral.h>
#include <Adafruit_NeoPixel.h>
// define pins (varies per shield/board)
#define BLE_REQ 10
#define BLE_RDY 2
#define BLE_RST 9

BLE Nano and the nRF51822 SDK

If you've tried using the nRF51822 SDK with the BLE Nano (after following the RedBearLab guide) you may have come to a dead end.

Even the simplest examples didn't work for me. I assumed I had a dead Nano (despite the upload process seeming to work fine).

The reason turned out to be that the latest SDK versions assume you have a nRF51822 chip with 32KB of RAM rather than the 16KB that the nRF51822 on the Nano has.

James Willcox explains this in a post to the RedBearLab BLE Nano support forum.

#include <util/delay.h>
#include <oled.h>
#include <tri.h>
void setup()
{
//Serial.begin( 115200 );
oled_init();
_delay_ms( 100 ); // Wait for the OLED display to come up.
/*
ffmpeg -i "$file" -f s32be -acodec pcm_s32be -ar 44100 -af "volume=0.5" tcp://espip:5522
*/
#include "i2s.h"
#include <ESP8266WiFi.h>
const char* ssid = "***********";
const char* password = "**********";
WiFiServer pcmServer(5522);
static WiFiClient pcmClient;
@chubin
chubin / Enable-wttr.in-for-PowerShell
Created February 22, 2016 22:19
How to enable wttr.in in a PowerShell console
# To enable ANSI sequences in a PowerShell console run the following commands.
# After that you can use wttr.in in you PowerShell just lake that:
# (curl http://wttr.in/ -UserAgent "curl" ).Content
#
# More on it:
# http://stknohg.hatenablog.jp/entry/2016/02/22/195644 (jp)
#
Add-Type -MemberDefinition @"
[DllImport("kernel32.dll", SetLastError=true)]
@rtfpessoa
rtfpessoa / handle-ctrl-c.py
Created March 19, 2016 11:28
Handle CTRL+C in Python
#!/usr/bin/env python
import signal
import sys
def signal_handler(signal, frame):
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)