Skip to content

Instantly share code, notes, and snippets.

View iegik's full-sized avatar
🧾
Looking for work

Arturs Jansons iegik

🧾
Looking for work
View GitHub Profile
@iegik
iegik / CookieManager.js
Created May 4, 2017 17:32
merged react-native-cookies and react-native-cookiemanager
import React from 'react';
import { Platform } from 'react-native';
import { HOST } from '../../api/constants';
import { serialize, parse } from 'cookie';
import { reduce, map, forEach, filter } from 'lodash';
export function callback(err, res) {
return res;
}
@iegik
iegik / _define.js
Last active December 15, 2017 12:45
Assign value to the context by key path
/**
* Assign value to the context by key path
* @param {array} path ['foo', 'bar']
* @param {mixed} value
* @returns {*} result {foo:{bar: value}}
*/
function _define (path, value){
return path.reduce((x, y, i) => {
return x[y] = i === path.length - 1 && typeof value !== 'undefined' ? value : x[y] || {};
}, this)
@iegik
iegik / CODESTYLE.md
Last active June 10, 2024 13:11
Frontend tips and tricks

Code Style

Add "precommit" script into package.json

npx mrm lint-staged
// Works out the width of elements based
// on total number of columns and width
// number of columns being displayed.
// Values for @grid would be 12, 16 or 24
.grid-inline-block(@grid: 12, @margin: 0, @width: 100%) {
@actions: column, prefix, suffix, pull, push;
.grid-action(block){
display: inline-block;
vertical-align: top;
@iegik
iegik / USDEUR.php
Created November 22, 2016 05:52
USD and EUR from Central Bank of Russia
<?php
$url = 'http://www.cbr.ru/scripts/XML_daily.asp';
$ch = curl_init( $url );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec( $ch );
curl_close($ch);
$xml = new SimpleXMLElement($result);
@iegik
iegik / README.md
Last active January 27, 2021 07:31 — forked from edwardbeckett/idea64.exe.vmoptions
Java 8 Intellij 64 JVM Options

Optimization settings for PHPStorm

~/Library/Preferences/PhpStorm*/phpstorm.vmoptions

@iegik
iegik / popup.js
Created November 4, 2016 13:08
Expose objects to popup window
t=this.open();
t.addEventListener('DOMContentloaded',(e)=>{
console.log(this, e);
e.target.close();
});
t.dispatchEvent(new CustomEvent('DOMContentloaded'));
@iegik
iegik / SpaceInviders.html
Last active November 3, 2016 11:27
Space Inviders
<body><script>eval('!function(t,i,s,h,n,o,e,a,r){function f(){var t=this.contro\
ls,i=this.id=this.id||(1e17*Math.random()).toString(32);this.I=function(s){for(\
var h in t)s.which===t[h]&&dispatchEvent(new Event(h+i))},this.A()}function p(t\
){return function(){var i,s=this.controls,h=this.id;for(i in s)t(i+h,this[i].bi\
nd(this));t(\"keydown\",this.I)}}function l(i){this.h=this.g=0,s(this,i),this.x\
=this.g,this.y=this.h,this.path=new t(this.d),f.apply(this,arguments),this.move\
To()}function u(){l.apply(this,arguments)}function d(){clearInterval(this.m),th\
is.i()}function y(){l.apply(this,arguments)}function v(){l.apply(this,arguments\
),this.o()}function b(t){var c=i.body.appendChild(i.createElement(\"canvas\"));\
s(this,t),c.height=1.5*(c.width=170),this.a=[],this.b=c.getContext(\"2d\"),f.ap\
@iegik
iegik / example.js
Last active November 29, 2017 13:11
Quick Sort
var a = [5,3,7,1,10,-1];
quicksort.call(a);
console.log(a); // -1, 1, 3, 5, 7, 10
@iegik
iegik / example.js
Last active October 30, 2016 19:12
SVG path data to array of objects
var d = 'M100,35c0-13-11-25-25-25s-25,12-25,18c0-5-11-18-25-18s-25,11-25,25c0,20,36,49,50,62,14-14,50-43,50-62z';
var pd = new PathData();
pd.fromString(d);
pd.scale(2)
pd.toString()