Skip to content

Instantly share code, notes, and snippets.

@xk
xk / count_2_one_million.hex
Created October 29, 2017 10:10
TOTAL INSANITY 6502 COUNT TO ONE MILLION
;see "Counting from 1 to 1,000,000 on the FASTChip" @ c.s.a2
;https://groups.google.com/forum/#!topic/comp.sys.apple2/ibI06hDLiaY
;See https://gist.github.com/xk/d2b95a4dcfc6f6fd40310dfeacb257da
1000:A0 B0 8C 05 04 8C 04 04
:8C 03 04 8C 02 04 8C 01
:04 8C 00 04 20 90 12 EE
:01 04 20 90 12 EE 01 04
:20 90 12 EE 01 04 20 90
@xk
xk / threads.c
Last active May 2, 2017 14:49
8 cores 96MB buffers
// 2017-04-30 jorge@jorgechamorro.com
// See http://www.eevblog.com/forum/projects/in-search-of-a-supercomputer
#include <pthread.h>
#include <stdlib.h>
#define BUF_SIZE 96*1024*1024
pthread_t t1, t2, t3, t4, t5, t6, t7, t8;
double* nu_buffer () { return (double*) malloc(BUF_SIZE); }
@xk
xk / threads.c
Last active May 2, 2017 14:48
Another useless benchmark to illustrate a point
// 2017-04-30 jorge@jorgechamorro.com
// See http://www.eevblog.com/forum/projects/in-search-of-a-supercomputer
#include <pthread.h>
#include <stdlib.h>
#define BUF_SIZE 16*1024*1024
pthread_t t1, t2, t3, t4;
double* nu_buffer () { return (double*) malloc(BUF_SIZE); }
@xk
xk / batteryMon.sh
Last active January 31, 2017 16:11
kindle loop #1
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 January 13, 2017 18:35
WIFI AUTO RECONNECT
#!/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 December 18, 2016 10:18
npm install node-gyp -g
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 December 11, 2016 22:20
node.js timers are borken
// 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 December 10, 2016 12:34
JavaScript execution wow and flutter
// 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 / brightness.c
Created February 11, 2014 22:02
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 / gist:8073619
Created December 21, 2013 19:16
Pone la hora de finalización al lado del artículo
javascript:[].filter.call(document.getElementsByClassName("g-clTRght"), function (e) {
return /^[0-9]+[hHmMsM]/.test(e.innerHTML);
}).forEach(function (e) {
var r, h, p, hora, minuto, segundo;
var txt= e.innerHTML;
if (/^[0-9]+[hH]/.test(txt)) {
r= /^([0-9]+)[hH] ([0-9]+)[mM]/.exec(txt);
h= new Date(Date.now() + (r[1]*60*60*1000) + (r[2]*60*1000));
}
else if (/^[0-9]+[mM]/.test(txt)) {