Skip to content

Instantly share code, notes, and snippets.

View thinklinux's full-sized avatar

Tihomir Valkanov thinklinux

  • Sofia, Bulgaria
View GitHub Profile
@thinklinux
thinklinux / KukuKubeBot.js
Last active March 21, 2019 11:01
Bot for the eye test game called Kuku Kube
// I little bot that I've made for the game Kuku Kube
// I found 2 bots so far and they were a lot slower than this one :)
// Start the game and paste the code in the browser's console. Hit enter and... don't watch! You can be hypnotized! :D
// You can play (or cheat) the game here http://106.186.25.143/kuku-kube/en-3/
// Have fun!
console.log('I\'m a bot')
var init = function () {
var color_arr = [],
@thinklinux
thinklinux / mup.json
Created June 30, 2015 14:36
nginx and meteor-up config for multiple meteor apps on digital ocean with SSL
...
"ssl": {
"pem": "./ssl.pem",
// When the ssl terminator finish its job it will redirect the request to 8080
// where our nginx will listen and proxy the request to our meteor app on port 3002 for example
// meteor-up uses stud for ssl temination so nginx will not deal with ssl at all
"backendPort": 8080
}
...
@thinklinux
thinklinux / fibonacci.js
Created August 22, 2015 18:47
Fibonacci with javascript
// start should be 0 or 1 because by definition fibonacci sequence is starting from 0 element with 0,1 or from the first element with 1,1
var start = 0// or 1;
var results = start == 0 ? [0, 1] : [1, 1];
var i = 0;
var end = 10; // how far you want to go
while(i < end) {
var len = results.length;
var next = results[len-1] + results[len-2];
results.push(next);
@thinklinux
thinklinux / sieve.js
Created August 22, 2015 20:13
Calculating prime numbers using Sieve of Eratosthenes
// https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
var sieve = [];
var primes = [];
var i, j;
var end = 1000;
for(i=2; i <= end; i++) {
if (!sieve[i]) {
primes.push(i);
@thinklinux
thinklinux / nginx.conf
Created April 16, 2016 15:01
Reverse proxy with basic auth for the Rethinkdb's Web UI
server {
listen 80;
server_name domain.com;
location /rethinkdb-admin/ {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.rethinkdb.pass;
proxy_pass http://127.0.0.1:8080/;
proxy_redirect off;
proxy_set_header Authorization "";
@thinklinux
thinklinux / xendo_sample_requests.js
Last active July 18, 2016 13:34
Xendo provisioning API
// All examples are using the request npm module
// Get
const qs = querystring.stringify({
email: email, // email of the user registered in xendo
service_name: 'asana',
access_token: access_token, // asana's access token for this user
refresh_token: refresh_token // asana's refresh token for this user
});
const url = 'https://xen.do/api/v1/provisioning/service/?' + qs;
@thinklinux
thinklinux / index.ios.js
Created November 7, 2018 14:59 — forked from Jpoliachik/index.ios.js
ReactNative LayoutAnimation Example
'use strict';
import React, {
AppRegistry,
Component,
StyleSheet,
Text,
View,
TouchableOpacity,
LayoutAnimation,
} from 'react-native';
@thinklinux
thinklinux / convert-svgs.js
Last active April 9, 2019 10:53 — forked from stowball/convert-svgs.js
A node script to convert a a folder of SVGs in to React Native SVGs for https://github.com/stowball/react-native-svg-icon
/* eslint-disable no-console, no-shadow */
const exec = require('child_process').exec;
const fs = require('fs');
// const type = process.argv[2] || 'icons';
const path = `./assets/svgs/originals`;
const svgoOptions = {
plugins: [
{ collapseGroups: true },
{ convertPathData: true },
@thinklinux
thinklinux / dispatching-action-creators.js
Created October 16, 2019 13:14 — forked from markerikson/dispatching-action-creators.js
Dispatching action creators comparison
// approach 1: define action object in the component
this.props.dispatch({
type : "EDIT_ITEM_ATTRIBUTES",
payload : {
item : {itemID, itemType},
newAttributes : newValue,
}
});
// approach 2: use an action creator function