Skip to content

Instantly share code, notes, and snippets.

View v-stickykeys's full-sized avatar
💫

stickykeys v-stickykeys

💫
View GitHub Profile
@v-stickykeys
v-stickykeys / popchain.js
Created May 27, 2018 03:24
node.js blockchain implementation
const SHA256 = require('crypto-js/sha256');
const cryptoRandomString = require('crypto-random-string');
class Block {
constructor(data) {
this.nonce = 0;
this.data = data;
this.previousHash = '';
this.timeCreated = Date.now(); //+ performance.now();
this.hash = this.calculateHash();
@v-stickykeys
v-stickykeys / soma_pizza.rs
Created August 17, 2018 05:07
Order pizza for your SF meetup! aka my first Rust program
use std::io;
fn main() {
println!("How many RSVPS do you have for your Meetup?");
let mut input = String::new();
io::stdin().read_line(&mut input)
.expect("Failed to read input.");
let trimmed = input.trim();
@v-stickykeys
v-stickykeys / single_threaded_rust_server.rs
Created August 17, 2018 18:37
Single threaded Rust server from the Rust Programming Language 2018 book
use std::io::prelude::*; // Traits that let us read and write to the stream
use std::net::TcpStream;
use std::net::TcpListener;
use std::fs; // Bring standard library File into scope
fn main() {
// bind returns a new TcpListener instances
// Connecting to a port to listen to is also called "binding to a port"
// bind returns a Result<T, E>
// unwrap will stop the program if errors occur
@v-stickykeys
v-stickykeys / mongo_shell_cheat_sheet.md
Last active September 22, 2018 17:59
mongo commands I need to know

Connect to mongo

$ mongo

What db am I in?

> db

What dbs do I have?

@v-stickykeys
v-stickykeys / dateTime.js
Created November 23, 2018 21:11
Lightest way to get the date and time in the format you want
const getTodayDefault = () => {
return new Date().toDateString();
}
const getTodayCondensed = () => {
return new Date().toLocaleDateString();
}
const getTodayExpanded = () => {
let d = new Date();
@v-stickykeys
v-stickykeys / 1_apolloClient.js
Last active December 20, 2018 09:39
Apollo Redux Super Fast
/*
3 Easy steps to get Apollo and Redux to play nicely super fast.
Configure the Apollo client
*/
import { ApolloClient } from 'apollo-client';
import { createHttpLink } from 'apollo-link-http'
import { InMemoryCache } from 'apollo-cache-inmemory';
@v-stickykeys
v-stickykeys / js_syntax_rules.js
Created June 13, 2019 15:54
JavaScript Syntax Rules
/* Comments
/**
* Describes what the function does and ends with a period.
*
* This is space to provide more explanation.
* @param { type } paramName Optionally provide more info.
* @return { type } Optionally provide more info.
*/
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'connorholyday/vim-snazzy'
@v-stickykeys
v-stickykeys / Dockerfile
Last active June 7, 2023 02:03
Dockerized Django Gunicorn app with Nginx SSL proxy
FROM python:3.7.4-alpine3.10
ADD replace_me/src/requirements.txt /app/requirements.txt
RUN set -ex \
&& apk add --no-cache --virtual .build-deps postgresql-dev build-base \
&& python -m venv /env \
&& /env/bin/pip install --upgrade pip \
&& /env/bin/pip install --no-cache-dir -r /app/requirements.txt \
&& runDeps="$(scanelf --needed --nobanner --recursive /env \
@v-stickykeys
v-stickykeys / simple-python-websocket
Created March 23, 2020 18:32
simple-python-websocket
#!/usr/bin/env python
# WS server example
# https://websockets.readthedocs.io/en/stable/intro.html
"""
`pip install websockets` then run as a script
"""
import asyncio