Skip to content

Instantly share code, notes, and snippets.

Avatar

Tihomir Valkanov thinklinux

View GitHub Profile
View dispatching-action-creators.js
// 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
@thinklinux
thinklinux / convert-svgs.js
Last active Apr 9, 2019 — 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
View convert-svgs.js
/* 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 / index.ios.js
Created Nov 7, 2018 — forked from Jpoliachik/index.ios.js
ReactNative LayoutAnimation Example
View index.ios.js
'use strict';
import React, {
AppRegistry,
Component,
StyleSheet,
Text,
View,
TouchableOpacity,
LayoutAnimation,
} from 'react-native';
View RethinkDB count issue and solutions.md
@thinklinux
thinklinux / xendo_sample_requests.js
Last active Jul 18, 2016
Xendo provisioning API
View xendo_sample_requests.js
// 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 / nginx.conf
Created Apr 16, 2016
Reverse proxy with basic auth for the Rethinkdb's Web UI
View nginx.conf
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 / sieve.js
Created Aug 22, 2015
Calculating prime numbers using Sieve of Eratosthenes
View sieve.js
// 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 / fibonacci.js
Created Aug 22, 2015
Fibonacci with javascript
View fibonacci.js
// 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 / mup.json
Created Jun 30, 2015
nginx and meteor-up config for multiple meteor apps on digital ocean with SSL
View mup.json
...
"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 / KukuKubeBot.js
Last active Mar 21, 2019
Bot for the eye test game called Kuku Kube
View KukuKubeBot.js
// 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 = [],