Skip to content

Instantly share code, notes, and snippets.

@zshell31
zshell31 / pins_evaluation.rs
Last active February 22, 2024 13:19
Pins evaluation at compile-time
#![feature(adt_const_params)]
#![feature(const_type_name)]
use std::marker::PhantomData;
trait HasSinglePin {}
struct Clock;
impl HasSinglePin for Clock {}
wus-www.sway-cdn.com
104.44.90.1
108.177.8.3
@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 / tab-trigger.js
Last active September 17, 2016 11:23 — forked from wesbos/tab-trigger.js
How to properly get a TAB trigger working with Emmet inside of JSX
// http://wesbos.com/emmet-react-jsx-sublime/
{
"keys": ["tab"],
"command": "expand_abbreviation_by_tab",
// put comma-separated syntax selectors for which
// you want to expandEmmet abbreviations into "operand" key
// instead of SCOPE_SELECTOR.
// Examples: source.js, text.html - source
"context": [
@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.