Skip to content

Instantly share code, notes, and snippets.

View ultrox's full-sized avatar
🏠
Working from home

Marko Vujanic ultrox

🏠
Working from home
View GitHub Profile
@ultrox
ultrox / TestSetupExampleCRAEnzymeChaiMocka.md
Created October 31, 2016 18:58 — forked from busypeoples/TestSetupExampleCRAEnzymeChaiMocka.md
Mocha/Chai/Enyzme test setup with create-react-app

Basic setup for using Enzyme/Mocha/Chai with create-react-app

This is a temporary solution. Might change in the near future, this depends on how create-react-app will implement testing.

create-react-app quick-test-example

cd quick-test-example

npm run eject
@ultrox
ultrox / index.html
Created November 24, 2016 13:55
Simple Pure CSS Drop Down Menu
<h1>Simple Pure CSS Drop Down Menu</h1>
<nav id="primary_nav_wrap">
<ul>
<li class="current-menu-item"><a href="#">Home</a></li>
<li><a href="#">Menu 1</a>
<ul>
<li><a href="#">Sub Menu 1</a></li>
<li><a href="#">Sub Menu 2</a></li>
<li><a href="#">Sub Menu 3</a></li>
<li><a href="#">Sub Menu 4</a>
@ultrox
ultrox / node-on-ec2-port-80.md
Created August 19, 2017 13:03 — forked from kentbrew/node-on-ec2-port-80.md
How I Got Node.js Talking on EC2's Port 80

The Problem

Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)

The temptingly easy but ultimately wrong solution:

Alter the port the script talks to from 8000 to 80:

}).listen(80);
@ultrox
ultrox / default.conf
Created December 15, 2017 08:54 — forked from cbmd/default.conf
nginx config - dynamic virtual hosts
server {
index index.php;
set $basepath "/var/www";
set $domain $host;
# check one name domain for simple application
if ($domain ~ "^(.[^.]*)\.dev$") {
set $domain $1;
set $rootpath "${domain}";
@ultrox
ultrox / ttfb.sh
Created January 2, 2018 17:49 — forked from sandeepraju/ttfb.sh
curl command to check the time to first byte
#!/bin/bash
# file: ttfb.sh
# curl command to check the time to first byte
# ** usage **
# 1. ./ttfb.sh "https://google.com"
# 2. seq 10 | xargs -Iz ./ttfb.sh "https://google.com"
curl -o /dev/null \
-H 'Cache-Control: no-cache' \
-s \
/* begin table creation */
create table department
(dept_id smallint unsigned not null auto_increment,
name varchar(20) not null,
constraint pk_department primary key (dept_id)
);
create table branch
(branch_id smallint unsigned not null auto_increment,
@ultrox
ultrox / webpack.config.babel.js
Created October 27, 2018 08:02
From how to build open source lib - Kent C. Dodds
//https://egghead.io/lessons/javascript-add-a-browser-build-to-an-npm-module
import { join } from "path";
export default {
entry: "./src/index.js",
output: {
path: join(__dirname, "dist"),
libraryTarget: "umd",
library: "starWarsNames"
},
@ultrox
ultrox / self-signed-certificate-with-custom-ca.md
Created November 4, 2018 10:07 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@ultrox
ultrox / elon_musk_first_principles.md
Created April 30, 2019 17:09
How to think in first principles

First principles battery

  • what are the materials constituents of batteries

  • what is spot market value of the material constituents

  • Cobalt, nickel, aluminium, carbon and polymers for separation and steel can.

Break that down on a material basis and say okay if we bought that in London metal exchange, what would each of those things cost. Its $80 per kilowatt hour

@ultrox
ultrox / git-rmf
Last active June 26, 2019 09:23
Permanently remove any file from repository!
#!/bin/bash
FILE=$1
if [[ -f $FILE ]]; then
git filter-branch -f --index-filter "git rm -r --cached $FILE --ignore-unmatch" --prune-empty --tag-name-filter cat -- --all
else
echo File required
fi