Skip to content

Instantly share code, notes, and snippets.

@cybic
cybic / disable_bluetooth_wake.sh
Created September 28, 2023 20:45
Disable wake by Bluetooth in Ventura
defaults -currentHost write com.apple.Bluetooth RemoteWakeEnabled 0
@cybic
cybic / consumer.spec.ts
Created January 8, 2019 12:59
Sinon FakeServer fail on not covered
beforeEach(() => {
fake = sinon.fakeServer.create();
// Fail on requests not covered by fakeserver
fake.respondWith(xhr => {
fail('FakeServer does not provide any result for URL ' + xhr.url)
});
fake.respondImmediately = true;
});
#!/bin/bash
# Reset xHCI
for xhci in /sys/bus/pci/drivers/?hci_hcd ; do
cd $xhci
echo Resetting devices from $xhci...
for i in ????:??:??.? ; do
echo -n "$i" > unbind
echo -n "$i" > bind
@cybic
cybic / get_failing_url.js
Created February 22, 2018 11:41
Get the URL of a failing SinonJS Fake Server request
// Put this before every other fake.respondWith() to make this a 404 fallback
fake.respondWith(xhr => {
console.log(xhr.url);
return [404, {}, 'Not found'];
});
@cybic
cybic / failingtests.sh
Last active February 13, 2018 09:54
Find failing tests
cat *txt | grep -B2 "Tests run:" | grep -v -- "--------" | grep -v "Failures: 0, Errors: 0" | grep -B1 "Tests run:"
@cybic
cybic / controlstrip-add.sh
Last active November 30, 2019 00:14
Additional button in collapsed control strip (touch bar)
# Add a button to the collapsed control strip part on the Apple MBP Touch Bar. The media button occationally added by itunes
# will be displaced.
defaults write com.apple.controlstrip MiniCustomized -array-add com.apple.system.notification-center
killall Controlstrip
#!/bin/bash
ADB=~/Downloads/android-sdk-macosx/platform-tools/adb
REMOTE='storage/sdcard0/DCIM/Camera/'
HERE='/Users/cybic/files/backup/R2D2-2/images'
FILES=$(diff <($ADB shell "ls $REMOTE" | sort | perl -pe "~ s/\r//" ) <( ls $HERE ) | grep \< | sed 's/\<\ //')
for f in $FILES
var Promise = require('es6-promise').Promise;
function test(a) {
return new Promise( function(resolve, reject){
console.log( 'Running %s', a );
setTimeout( resolve.bind( this, 'dønn ' + a ), 5000);
});
}
@cybic
cybic / idp.mapcss
Last active August 29, 2015 14:20
area:closed|z14-[damage:event] {
fill-color: #ffffff;
color: red;
width: 2;
}
area|z14-[idp:camp_site] {
fill-color: #00ff00;
}
@cybic
cybic / remux-hop
Last active January 24, 2020 11:55
#!/bin/bash
#
# AutoSSH to host and create or connect to tmux session
# Multi-hop version. Separate hops with `%`. Assign port with `:`
#
# $ remux-hop server.example.com sysop
# $ remux-hop alice.example.com%bob.example.com sysop
# $ remux-hop alice.example.com%bob@bob.example.com:2222 sysop
#
# Author: Oystein Steimler <oystein@nyvri.net>