Skip to content

Instantly share code, notes, and snippets.

@zshell31
zshell31 / react-native-pinch-zoom.js
Created September 19, 2016 13:32
React Native: how to implement pinch to zoom gesture
/** Links:
* - http://stackoverflow.com/questions/36368919/scrollable-image-with-pinch-to-zoom
* - http://blog.lum.pe/gesture-detection-in-react-native-fixing-unexpected-panning/
*
*/
import React, {Component, PropTypes} from 'react';
import { Text, View, PanResponder, Image } from 'react-native';
function calcDistance(x1, y1, x2, y2) {
@zshell31
zshell31 / changing-dots-optical-illusion-w-bg-gradients.markdown
Created September 15, 2016 18:30
"changing dots" optical illusion w/ bg gradients😎😵

"changing dots" optical illusion w/ bg gradients😎😵

Creating another optical illusion with CSS.

As your eyes move around the page, the dots should change between white and black.

Simply made with a combination of background size and use of gradients.

Enjoy!

@zshell31
zshell31 / api_calls.js
Last active July 1, 2016 10:09
Json Server Api calls
function api(method, uri, body) {
url = 'http://localhost:3000/' + uri;
return fetch(url, {
method: method,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
})
@zshell31
zshell31 / receve-apt-keys.sh
Last active March 12, 2016 11:38
Receive public keys for repositories for which public keys are not found by apt-get
* For details: https://www.opennet.ru/base/sec/gpg_crypt.txt.html
* Also: http://f3arnil.blogspot.ru/2011/06/linux-apt-key.html
#!/bin/sh
KEY_SERVER=p80.pool.sks-keyservers.net
if [ -z $1 ]
then
KEYS='sudo apt-get -qq update 2>&1 | awk '/NO_PUBKEY/ {print($NF)}' | uniq | tr '\n' '\ ''
@zshell31
zshell31 / curry.js
Last active March 7, 2016 08:46
Currying in js
var DEBUG = false;
var debug = function(msg) {
if (DEBUG) {
console.log(msg);
}
}
Function.prototype.curry = function() {
this.argList || (this.argList = []);
@zshell31
zshell31 / copy.c
Created January 22, 2016 12:54 — forked from ThiefMaster/copy.c
copy
/* Copy a regular file from SRC_NAME to DST_NAME.
If the source file contains holes, copies holes and blocks of zeros
in the source file as holes in the destination file.
(Holes are read as zeroes by the `read' system call.)
When creating the destination, use DST_MODE & ~OMITTED_PERMISSIONS
as the third argument in the call to open, adding
OMITTED_PERMISSIONS after copying as needed.
X provides many option settings.
Return true if successful.
*NEW_DST is as in copy_internal.
@zshell31
zshell31 / what-forces-layout.md
Created November 30, 2015 07:38 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
var next = function(p, $scope) {
var create = function($scope, time) {
var time = time || 1000;
return new Promise(function(resolve, reject) {
setTimeout(function() {
console.log("Promise: " + $scope.val);
$scope.val++;
resolve($scope);
}, time);
});