Skip to content

Instantly share code, notes, and snippets.

View dakk's full-sized avatar
Working from boat

Davide Gessa dakk

Working from boat
View GitHub Profile
@dakk
dakk / sailaway_on_linux.bash
Last active January 15, 2018 08:33
How to play SailAway simulator on Linux
# For those attempting to install and use it on Linux, this is a quick howto (not really a bash script):
# 1. Download and install Steam with wine
# 2. Start steam and install sailaway
wine Steam.exe
# 3. Now wine will automatically use the wrong version of directx (d3d11); open winecfg, go to libraries, in
# "New override library" search for d3d11 and click "Add". Then click in d3d11 in "Existing override" and click "Edit"
# then switch the combo to "Disable"; press on "Apply" and close winecfg
@dakk
dakk / promise_all_step.js
Created December 14, 2016 16:29
Execute a promise list, n at time
/* Execute a promise list, n at time */
Promise.prototype.allStep = (promiseList, n) => {
let promises = [];
for (let i = 0; i < promiseList.length; i+=n) {
promises.push (new Promise ((resolve, reject) => {
var p = promiseList.slice (i, i+n ? i+n <= promiseList.length : promiseList.length);
Promise.all (p).then ((r) => {
resolve (r);
@dakk
dakk / bind.sh
Created November 24, 2016 09:12
Bind your vps port to a local port without proxy settings
ssh root@vps -L9305:127.0.0.1:9306
@dakk
dakk / boost.mk
Created November 4, 2016 17:42
Boost.mk for compiling ZCash on gentoo / funtoo
package=boost
$(package)_version=1_62_0
$(package)_download_path=http://sourceforge.net/projects/boost/files/boost/1.62.0
$(package)_file_name=$(package)_$($(package)_version).tar.bz2
$(package)_sha256_hash=36c96b0f6155c98404091d8ceb48319a28279ca0333fba1ad8611eb90afb2ca0
$(package)_patches=deprecated_auto_ptr.patch
define $(package)_set_vars
$(package)_config_opts_release=variant=release
$(package)_config_opts_debug=variant=debug
#define HASH_SIZE 32
typedef struct block_t {
data: uint8_t [HASH_SIZE];
};
void hash (uint8_t *data, block_t *h) {
}
import random
betRange = [79.0, 81.0]
def doBet (bet, winRange, mul):
r = random.randint (1, 9999) / 100.0
if r >= winRange[0] and r <= winRange[1]:
return bet * mul
else:
return -bet
#!/usr/bin/python2
import urllib2 as ul2
import time
while True:
ip = ul2.urlopen('http://ipecho.net/plain').read()
f = open('/home/dak/Dropbox/ip.txt','w')
f.write(ip)
f.close()
time.sleep (60)
x = -1.01:.001:1.01;
y = 4/5*(sqrt(1-x.^2) + sqrt(abs(x)));
z = 4/5*(-sqrt(1-x.^2) + sqrt(abs(x)));
plot(x,y,'r');
plot(x,z,'r');
#include <stdio.h>
#include <malloc.h>
#define N 8
/** Recursive delete like a pro
* where: 'ar' is the array, 'n' is the size, 'start' is 0 when
* called first time, 'irem' is the index of element to remove.
* @return the new size of the array (n-1)
#include <stdio.h>
#include <malloc.h>
#define N 9
#define M 5
void print_ar (int *a, int n)
{
for (int i=0;i<n;i++) printf ("%d ", a[i]);