Skip to content

Instantly share code, notes, and snippets.

View xeoncross's full-sized avatar

David Pennington xeoncross

View GitHub Profile
@xeoncross
xeoncross / Every possible TypeScript type.md
Created January 10, 2020 21:48 — forked from laughinghan/Every possible TypeScript type.md
Diagram of every possible TypeScript type

Hasse diagram of every possible TypeScript type

  • any: magic, ill-behaved type that acts like a combination of never (the proper [bottom type]) and unknown (the proper [top type])
    • Anything at all is assignable to any, and any is assignable to anything at all.
    • Identities: any & AnyTypeExpression = any, any | AnyTypeExpression = any
    • Key TypeScript feature that allows for [gradual typing].
  • unknown: proper, well-behaved [top type]
    • Anything at all is assignable to unknown. unknown is only assignable to itself (unknown) and any.
    • Identities: unknown & AnyTypeExpression = AnyTypeExpression, unknown | AnyTypeExpression = unknown
  • Prefer over any whenever possible. Anywhere in well-typed code you're tempted to use any, you probably want unknown.
@xeoncross
xeoncross / Webserver.c
Created November 19, 2012 21:05
A web server in C language using only the standard libraries and thought it would be useful for you guys if I share the code. The server runs on Linux and includes features like handling HTTP GET request, handling content types(txt, html, jpg, zip. rar,
/*
* WebServer.c
*
* Created on: Nov 3, 2012
* Author: pavithra
*
* A web server in C language using only the standard libraries.
* The port number is passed as an argument.
*
* http://css.dzone.com/articles/web-server-c
<?php
$compressed = array(
".0" => "Hacha Split Archive File",
".000" => "DoubleSpace Compressed File",
".7z" => "7-Zip Compressed File",
".7z.001" => "7-Zip Split Archive Part 1 File",
".7z.002" => "7-Zip Split Archive Part 2 File",
".a00" => "ALZip Second Split Archive File",
".a01" => "ALZip Third Split Archive File",
@xeoncross
xeoncross / driver.go
Created May 19, 2021 01:50 — forked from kamichidu/driver.go
POC: golang database/sql, row to map[string]interface{} mapping
package main
import (
"database/sql"
"database/sql/driver"
"fmt"
"strings"
)
type Mapper interface {
@xeoncross
xeoncross / grab.php
Created January 4, 2014 21:46 — forked from zofe/grab.php
<?php
function grab_page($url, $data=array())
{
$agent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1';
$referer = "http://www.bing.com";
$url = str_replace(' ', '%20', $url);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
const LONG = 26;
const SHORT = 12;
const MID = 9;
function sum(inputs) {
return inputs.reduce((s, v) => s + v, 0);
}
function average(N, inputs) {
return sum(inputs.slice(0, N)) / N;
@xeoncross
xeoncross / .block
Created March 12, 2021 15:27 — forked from rrag/.block
CandleStickChart with MACD Indicator
license: MIT
height: 620
@xeoncross
xeoncross / YouTubeURLFormats.txt
Created January 16, 2021 03:55 — forked from rodrigoborgesdeoliveira/ActiveYouTubeURLFormats.txt
Example of the various YouTube url formats
http://www.youtube.com/watch?v=-wtIMTCHWuI
http://www.youtube.com/v/-wtIMTCHWuI?version=3&autohide=1
http://youtu.be/-wtIMTCHWuI
http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json
http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare
@xeoncross
xeoncross / use-auth.js
Created August 5, 2019 16:12 — forked from timc1/use-auth.js
React Context + Hooks + Firebase Authentication
import React from 'react'
import firebaseConfig from '../path/to/firebase-config'
import firebase from 'firebase/app'
import 'firebase/auth'
import FullPageLoading from '../path/to/full-page-loading'
AuthProvider.actions = {
setUser: 'SET_USER',
toggleLoading: 'TOGGLE_LOADING',
}
@xeoncross
xeoncross / aes.go
Created October 16, 2020 03:00 — forked from tscholl2/aes.go
simple AES encryption/decryption example with PBKDF2 key derivation in Go, Javascript, and Python
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"fmt"
"strings"