Skip to content

Instantly share code, notes, and snippets.

xk xk

Block or report user

Report or block xk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@xk
xk / batteryMon.sh
Last active Jan 31, 2017
kindle loop #1
View batteryMon.sh
sleep 1
# Apagar/parar cosas:
/etc/init.d/framework stop
/etc/init.d/powerd stop
/etc/init.d/pmond stop
killall webreader
# killall browserd NO VA NO SE POR QUÉ
killall browserd
killall tmd
@xk
xk / auto_wifi.sh
Last active Jan 13, 2017
WIFI AUTO RECONNECT
View auto_wifi.sh
#!/bin/bash
# The IP for the server you wish to ping
SERVER=192.168.100.1
sleep 30s
while [ 1 ]; do
# Only send two pings, sending output to /dev/null
ping -c2 ${SERVER} > /dev/null
# If the return code from ping ($?) is not 0 (meaning there was an error)
@xk
xk / npm-debug.log
Created Dec 18, 2016
npm install node-gyp -g
View npm-debug.log
root@opi1:~# cat npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/root/.nvm/v0.10.0/bin/node',
1 verbose cli '/root/.nvm/v0.10.0/bin/npm',
1 verbose cli 'install',
1 verbose cli 'node-gyp',
1 verbose cli '-g' ]
2 info using npm@1.2.14
3 info using node@v0.10.0
4 verbose read json /root/.nvm/v0.10.0/lib/package.json
@xk
xk / checktimers.js
Last active Dec 11, 2016
node.js timers are borken
View checktimers.js
// 2016-12-10 jorge@jorgechamorro.com
// node.js timers are borken: node checktimers.js errs all the time
// But this won't ever err in a browser: copy-paste in any browser's console
// Update: somewhere between node 0.10.26 and 0.12.0 this has been fixed
(function (ctr,flag,errors) {
function _1 () { flag= 0 }
function _2 () { errors+= flag }
function _3 () { flag= 1 }
@xk
xk / flutter.js
Last active Dec 10, 2016
JavaScript execution wow and flutter
View flutter.js
// 2016-11-29 jorge@jorgechamorro.com
// JavaScript execution wow and flutter
var MAX_ms= -1;
var r, now, ctr, str;
var MAX_ctr= -1;
var MIN_ctr= 10e9;
function sync (now,r) {
now= Date.now()+ 1;
@xk
xk / buscarVariablesGlobales.js
Created Nov 5, 2015
Muestra las variables globales
View buscarVariablesGlobales.js
(function buscarVariablesGlobales (dirtySet, cleanSet) {
//© 2013-02-19 jorge@jorgechamorro.com
dirtySet= document.body.appendChild(document.createElement('iframe'));
cleanSet= Object.getOwnPropertyNames(dirtySet.contentWindow);
dirtySet.parentNode.removeChild(dirtySet);
dirtySet= Object.getOwnPropertyNames(function () { return this }());
return dirtySet.filter(function (v,i,o) { return cleanSet.indexOf(v) < 0 });
})()
@xk
xk / blocks.js
Created Mar 10, 2014
Blocks === multiline
View blocks.js
/*!
multiline
Multiline strings in JavaScript
https://github.com/sindresorhus/multiline
by Sindre Sorhus
MIT License
*/
(function () {
'use strict';
@xk
xk / brightness.c
Created Feb 11, 2014
Brightness.c
View brightness.c
/* gcc -std=c99 -o brightness brightness.c -framework IOKit -framework ApplicationServices */
#include <stdio.h>
#include <unistd.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#include <ApplicationServices/ApplicationServices.h>
const int kMaxDisplays = 16;
const CFStringRef kDisplayBrightness = CFSTR(kIODisplayBrightnessKey);
const char *APP_NAME;
@xk
xk / happyNumbers.c
Created Feb 10, 2014
Happy Numbers in C
View happyNumbers.c
//2014-02-10 jorge@jorgechamorro.com happy numbers in C
#include<stdio.h>
unsigned sumaCuadrados (unsigned n) {
unsigned d, r= 0;
while (n) d= n % 10, r+= d*d, n/= 10;
return r;
}
@xk
xk / happyNumbers.js
Created Feb 10, 2014
Concise Happy Numbers JavaScript
View happyNumbers.js
//2014-02-10 jorge@jorgechamorro.com concise happy numbers JavaScript
function happy (n) {
var past= [];
while (n= [].reduce.call(n.toString(), function (a,n) { return a+n*n }, 0))
if (n === 1) return 1; else if (past.indexOf(n) >= 0) return 0; else past.push(n);
}
for (var i=0 ; i<=100 ; ++i) happy(i) && console.log(i);
You can’t perform that action at this time.