Skip to content

Instantly share code, notes, and snippets.

@sillyslux
sillyslux / init.coffee
Last active March 25, 2016 23:08
Atom setup
atom.contextMenu.add
'atom-text-editor': [{
type: 'separator'
},{
label: 'fold all'
command: 'editor:fold-all'
},{
label: 'unfold all'
command: 'editor:unfold-all'
},{
@sillyslux
sillyslux / ping.html
Last active November 29, 2017 22:47
funny ping hack for browser tabs
<script>
window.addEventListener('storage',evt=>evt.key==='pingAll'&&console.log("got pinged"))
window.addEventListener('focus',()=>localStorage.setItem('pingAll',Date.now())||console.log("ping"))
</script>
@sillyslux
sillyslux / a themeswitch.sh
Last active January 27, 2020 12:48
automated theme switching for flluxbox
#!/bin/bash
#
# automate switching between dark and light themes in fluxbox. it currently
# changes themes of fluxbox, gtk2/3, tint2, hexchat and liferea.
declare -A BRIGHTNESS=( [light]=100 [dark]=0 )
# declare -A BRIGHTNESS=( [light]=4 [dark]=6 )
declare -A VSCODE_THEME=(
[light]="Atom One Light"
@sillyslux
sillyslux / isRunning.sh
Created November 29, 2017 20:39
a few shell functions
#!/bin/sh
# descr: chainable "isRunning" functions
# Usage: R conky && echo "conky is running" || echo "conky is not running"
# S conky && echo "do something with $pid and $pcmd" || echo "do something else"
# simple isRunning function
R () {
pidof $1 > /dev/null
return $?
}
@sillyslux
sillyslux / asybn.js
Last active January 25, 2018 10:59 — forked from theSekyi/asybn.js
const getOldNavDaily = oldNavUrl => fetch(oldNavUrl)
.then(resp => resp.json())
.then(data => data.payload.nav);
getOldNavDaily('//example.com/getOldNavDaily.php').then(console.log);
@sillyslux
sillyslux / nodestress.js
Created February 16, 2018 13:00
multiple threads from node stress testing the cpu
const shell = require('shelljs');
const nexec = cmd => new Promise((resolve, reject) => {
shell.exec(cmd, (code, stdout, stderr) => {
if(stderr) reject(stderr);
if(code) reject(new Error('exit code'));
if(stdout) resolve(stdout);
reject(new Error('unexpected behaviour'));
})
});
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceFolder}"
],
"defines": [],
@sillyslux
sillyslux / nvm_loader1.sh
Last active September 21, 2019 15:59
delaying nvm load until first usage in session
#!/bin/bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
-----
$ time source ./nvm_loader1.sh
@sillyslux
sillyslux / someComponent.jsx
Last active October 9, 2019 12:24
win/mac/linux theme change listener for react
import React from 'react';
import { themeChange } from '../../../style/theme';
...
themeChange.subscribe(console.log); // logs dark/light
// ==UserScript==
// @name jsfiddle auto dark switch
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @include https://jsfiddle.net/*
// @grant none
// ==/UserScript==