Skip to content

Instantly share code, notes, and snippets.

View nikosolihin's full-sized avatar

Niko Solihin nikosolihin

  • Grand Rapids, MI
View GitHub Profile
@nikosolihin
nikosolihin / ID.js
Created November 7, 2017 15:22
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@nikosolihin
nikosolihin / curl.md
Created January 29, 2018 04:59 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@nikosolihin
nikosolihin / Carousel.js
Created March 16, 2018 01:25 — forked from JoshBarr/Carousel.js
Flickity React integration
@nikosolihin
nikosolihin / repeater-meta.php
Created June 26, 2018 02:21 — forked from izzygld/repeater-meta.php
Hooking up ACF repeater fields to the shema.
//acf stats repeater
array (
'key' => 'field_5a27ee3a83076',
'label' => 'Stats',
'name' => 'stats',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
@nikosolihin
nikosolihin / index.jsx
Created November 4, 2018 07:20 — forked from drcmda/index.jsx
react-spring with react-native
import React from 'react'
import { StyleSheet, Text, View, TouchableWithoutFeedback } from 'react-native'
import { Spring, animated } from 'react-spring/dist/native'
const styles = {
flex: 1,
margin: 0,
borderRadius: 35,
backgroundColor: 'red',
alignItems: 'center',
@nikosolihin
nikosolihin / package.json
Created November 7, 2018 04:54 — forked from mburakerman/package.json
Webpack 4 config.js (SCSS to CSS and Babel) 👌 The Simplest Usage 👌
{
"name": "webpack-sass",
"version": "1.0.0",
"scripts": {
"start": "webpack-dev-server --open --mode development",
"build": "webpack -p"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
const startDate =
location.state && location.state.startDate ? location.state.startDate : today
const prevStartRef = useRef(startDate)
let transitionDirection
if (prevStartRef.current !== startDate) {
transitionDirection = startDate < prevStartRef.current ? "earlier" : "later"
prevStartRef.current = startDate
}
@nikosolihin
nikosolihin / cpu.js
Created June 28, 2019 08:12 — forked from bag-man/cpu.js
How to calculate the current CPU load with Node.js; without using any external modules or OS specific calls.
var os = require("os");
//Create function to get CPU information
function cpuAverage() {
//Initialise sum of idle and time of cores and fetch CPU info
var totalIdle = 0, totalTick = 0;
var cpus = os.cpus();
//Loop through CPU cores
@nikosolihin
nikosolihin / list.py
Created July 19, 2019 03:52 — forked from RatulSaha/list.py
Useful List tricks in Python
#List traversal
range(start, stop, hop)
range(n) # [0,1,...,n-1]
range(1,n) # [1,...,n-1]
range(1,n,2) # [1,3,5,...,n-1] if n is even, or [1,3,5,...,n-2] if n is odd
range(n,-1,-1) # [n,n-1,n-2,...,0]
range(len(arr)) # Provides indices of an array arr
range(len(arr)-1,-1,-1) # Provides indices of arr backwards
# List slicing
@nikosolihin
nikosolihin / pipenv_cheat_sheet.md
Created July 23, 2019 02:24 — forked from bradtraversy/pipenv_cheat_sheet.md
Pipenv cheat sheet for common commands

Pipenv Cheat Sheet

Install pipenv

pip3 install pipenv

Activate

pipenv shell