Skip to content

Instantly share code, notes, and snippets.

View DanBUK's full-sized avatar

Daniel Bartlett DanBUK

View GitHub Profile
var unfav = document.getElementsByClassName('with-icn unfavorite js-tooltip')[0];
var fav = document.getElementsByClassName('with-icn favorite js-tooltip')[0];
var count = 0;
var max_count = 100;
var timInterval = setInterval(function () {
fav.click();
setTimeout(function () {
unfav.click();
count++;
if (count == max_count) clearInterval(timInterval);
@DanBUK
DanBUK / sandbox_it.js
Created January 23, 2011 15:10
Chroot'ed node processes!
root 31098 0.0 0.5 15500 2180 pts/1 S 14:15 0:00 | \_ -bash
dan 31361 0.2 2.3 626500 8964 pts/1 Sl+ 15:08 0:00 | \_ node sandbox_it.js
[dan@arch-vm node-daemon-tools]$ curl http://127.0.0.1:8124/
Hello World
Current directory: /
err: null
files: [ 'hello.js' ]
@DanBUK
DanBUK / gist:1069823
Created July 7, 2011 15:52
nodester test push
[dan@m-box 834-327ffd51d202655c750101d7267a987d]$ git commit -m "Test whitespace." app.js
[master f7ed059] Test whitespace.
1 files changed, 1 insertions(+), 0 deletions(-)
[dan@m-box 834-327ffd51d202655c750101d7267a987d]$ git push
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 286 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Syncing repo with chroot
@DanBUK
DanBUK / gist:1070014
Created July 7, 2011 17:13
nodester issue #122 example
> var o = /^.*$/;
> o
/^.*$/
> o.concat
> o.concat('asdf')
TypeError: Object /^.*$/ has no method 'concat'
at [object Context]:1:3
at Interface.<anonymous> (repl.js:171:22)
at Interface.emit (events.js:64:17)
at Interface._onLine (readline.js:153:10)
@DanBUK
DanBUK / find_primes.js
Created July 19, 2011 16:27
Find prime numbers
// Converted to Javascript by Daniel Bartlett [DanBUK] <dan@f-box.org>
// Source: http://en.wikibooks.org/wiki/Efficient_Prime_Number_Generating_Algorithms
var find_primes = function (max_prime) {
/* Get the square root of the upper limit. This will be the upper limit of the test prime array
for primes used to verify the primacy of any potential primes up to (max_prime). Primes greater than
(sqrtlim) will be placed in an array for extended primes, (xp), not needed for the verification
test. The use of an extended primes array is technically unnecessary, but helps to clarify that we
have minimized the size of the test prime array.
*/
@DanBUK
DanBUK / do_tim_over.js
Created October 20, 2012 22:09
timthumb.php DoS example
#!/usr/bin/env node
var domain = 'www.example.com';
var port = 80;
var ttpath = '/wp-content/themes/example/timthumb.php';
var src_list = [
'http://www.example.com/wp-content/uploads/2012/01/example.jpg',
'http://www.example.com/wp-content/uploads/2012/01/example1.jpg'
];
@DanBUK
DanBUK / bugmulti.c
Created October 29, 2012 08:15
Program does "big multiplication" - Should be able to handle numbers of _ANY_ length
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
/* Program does "big multiplication"
Should be able to handle numbers of _ANY_ length
Input via stdin:-
N
@DanBUK
DanBUK / custom_c_arrays.c
Created October 31, 2012 18:34
i don't know what I hate segfaults
typedef struct {
int size;
short *digits;
} IntArray;
typedef struct {
int size;
IntArray **arrays;
} IntArrayOfArray;
@DanBUK
DanBUK / hello.js
Last active December 14, 2015 11:39
TCP Hello TCP Daemon
#!/bin/env node
var NET = require('net');
var ClientHandler = function (conn) {
this.bkspace = new Buffer([8,8,8]);
this._conn = conn;
this._running = true;
this._remoteAddress = this._conn.remoteAddress;
this._remotePort = this._conn.remotePort;
@DanBUK
DanBUK / rsync_wrapper.c
Created March 6, 2013 07:55
rsync wrapper
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>
#define CONF_FILE "/etc/rsync_secure.conf"
typedef struct {