Skip to content

Instantly share code, notes, and snippets.

View hoggren's full-sized avatar
💾

Patrik Höggren hoggren

💾
View GitHub Profile
@hoggren
hoggren / Airfoilspeakers daemon with node.js
Created April 18, 2016 12:43
Spawns an airfoilspeakers instance
var fs = require('fs');
var spawn = require('child_process').spawn;
var airfoil = spawn('airfoilspeakers');
var wStream = fs.createWriteStream('./airfoil.log');
airfoil.stdout.pipe(wStream);
@hoggren
hoggren / unload_smartcard.sh
Last active February 12, 2018 16:48
Unload OSX / macOS smartcard driver
#!/bin/bash
#
# Unload OSX / macOS smartcard driver
# Useful for libnfc
#
# Solves the error:
# ~ $ nfc-list
# nfc-list uses libnfc libnfc-1.7.1-66-g24979c6
# error libnfc.driver.acr122_usb Unable to claim USB interface (Permission denied)
# nfc-list: ERROR: Unable to open NFC device: acr122_usb:020:002
@hoggren
hoggren / define-shell-colors.sh
Last active May 23, 2024 03:57
Terminal / shell / bash color modifiers to colorize your output!
#!/bin/bash
# Special characters that modifies the output with coloring.
# Characters after one of these will be in the specified color until another
# color or reset character is specified.
# Color character modifiers
BLACK="\033[30m"
RED="\033[31m"
@hoggren
hoggren / parse.js
Created July 6, 2016 16:34
Parse querystring javascript
var parseQuery = function(uri) {
var query = {};
var uri = uri.split('?');
if(uri.length == 0) return null;
var rawQuery = decodeURIComponent(uri[1]);
rawQuery = rawQuery.split('&');
if(rawQuery.length == 0) return null;
@hoggren
hoggren / ios_packet_tracing.md
Last active July 9, 2016 19:17
IOS Package tracing

IOS packet tracing

Connect your IOS device to a Mac via USB. Create a virtual network interface which the IOS traffic will tunneled through Trace packets using Wireshark/tcpdump You will need your device's UID which can be obtained by iTunes.

Run in terminal:

rvictl -s <device_id>
@hoggren
hoggren / cheat.js
Last active October 12, 2016 15:22
Cheat for lingonspelet (fusk för lingonspelet.se)
// Fusk för lingonspelet.se, klistra in i Javascript-consolen
// For eductional purposes only!!
eval(String.fromCharCode(118,97,114,32,117,112,100,97,116,101,71,97,109,101,61,102,117,110,99,116,105,111,110,40,41,123,32,118,97,114,32,97,61,112,108,97,121,101,114,59,118,97,114,32,98,61,112,108,97,121,101,114,65,99,116,105,111,110,59,118,97,114,32,99,61,100,105,114,101,99,116,105,111,110,115,59,118,97,114,32,100,61,116,114,117,101,59,118,97,114,32,120,61,100,114,97,119,83,116,97,103,101,59,118,97,114,32,121,61,114,101,113,117,101,115,116,65,110,105,109,70,114,97,109,101,59,118,97,114,32,122,61,103,97,109,101,111,118,101,114,59,97,46,120,43,61,99,91,99,100,93,46,120,42,97,46,115,112,101,101,100,59,97,46,121,43,61,99,91,99,100,93,46,121,42,97,46,115,112,101,101,100,59,118,97,114,32,100,61,116,114,117,101,59,105,102,40,97,46,120,60,61,48,41,123,97,46,120,61,53,59,98,40,41,59,125,105,102,40,97,46,121,32,60,61,32,48,41,123,97,46,121,61,53,59,98,40,41,59,125,105,102,40,97,46,120,62,61,40,53,48,48,45,97,46,119,105,100,
@hoggren
hoggren / tasks.json
Last active December 22, 2019 12:23
ESLINT all files in editor using ESLINT
/*
Protip: Can be bound to a key binding! ;)
If you want to lint on a keybinding,
add this to 'keybindings.json':
{
"key": "cmd+k cmd+l",
"command": "workbench.action.tasks.runTask",
"args": "Lint workspace",
"when": "editorTextFocus"
@hoggren
hoggren / mssqlserver.sql
Last active February 17, 2019 14:06
SQL Snippets
/**
* Reset identity counter to next value - for example after deleting rows
*/
DECLARE @max INT
SELECT @max = MAX(ID)
FROM [dbo].[tablename]
IF @max IS NULL
SET @max = 0
DBCC CHECKIDENT ([dbo].[tablename], RESEED, @max);
@hoggren
hoggren / chrome-no-auto-searchengines.sql
Created March 2, 2019 08:40
Deletes autocreated Chrome search engines, i.e. keyword search in address bar
-- SQLite database file: Web Data
-- Locations:
-- * MacOS: ~/Library/Application Support/Google/Chrome/Default
-- * Windows: %LOCALAPPDATA%/Google/Chrome/Default
--
-- Reference: https://superuser.com/questions/276069/google-chrome-automatically-adding-websites-to-my-list-of-search-engines
CREATE TRIGGER no_auto_keywords
BEFORE INSERT
ON keywords
WHEN (NEW.originating_url IS NOT NULL AND NEW.originating_url != '')
@hoggren
hoggren / print-arguments.sh
Created March 15, 2019 16:35
Get all arguments into one array - without the application name
#!/bin/bash
# Test run: ./print-arguments.sh arg1 arg2 arg3 arg4
#
# Author: Patrik Hoggren <p@hoggren.nu>
# https://www.github.com/phoggren
ARGS=("$@");
# print ALL arguments
echo "${ARGS[*]}";