Skip to content

Instantly share code, notes, and snippets.

View optozorax's full-sized avatar

ilya sheprut optozorax

View GitHub Profile
@cdown
cdown / gist:1163649
Last active July 1, 2024 03:35
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@nuxlli
nuxlli / sublime_text_2_useful_shortcuts.md
Created September 9, 2011 18:51 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@jaydenseric
jaydenseric / ffmpeg-web-video-guide.md
Last active July 3, 2024 19:58
A quick guide to using FFmpeg to create cross-device web videos.

Video conversion with FFmpeg

Install

On mac:

  1. Download the latest release.
  2. Extract the binary and place it in /usr/local/bin.

Command basics

@jgravois
jgravois / _webserver.md
Last active July 20, 2024 10:43
a simple guide for getting a local web server set up

Do I have a web server running?


having a web server turned on doesn't necessarily mean you are serving pages on the world wide web. its what allows you to load your own static files (.html, .js etc.) in a browser via http://.

if you're not sure whether or not you have a web server running, no problem! its easy to confirm.

what happens when you visit http://localhost/?

@superfawkes
superfawkes / git-svn-diff.sh
Created June 22, 2016 12:15
Git Diff to Svn Diff - compatible with Crucible andCode Review software
#!/bin/bash
#
# git-svn-diff originally by (http://mojodna.net/2009/02/24/my-work-git-workflow.html)
# modified by mike@mikepearce.net
# modified by aconway@[redacted] - handle diffs that introduce new files
# modified by superfawkes - correct whitespaces in aconway's patch for Crucible, handle whitespaces for BSD/OSX styled sed
#
# Generate an SVN-compatible diff against the tip of the tracking branch
# Get the tracking branch (if we're on a branch)
@KodrAus
KodrAus / Profile Rust on Linux.md
Last active November 14, 2023 17:19
Profiling Rust Applications

Profiling performance

Using perf:

$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg

NOTE: See @GabrielMajeri's comments below about the -g option.

@ugik
ugik / sample code from tflearn ANN
Last active April 29, 2018 14:14
2-layer perceptron code from tflearn example
# Build neural network
net = tflearn.input_data(shape=[None, 5])
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net)
# Define model and setup tensorboard
model = tflearn.DNN(net, tensorboard_dir='tflearn_logs')
# Start training (apply gradient descent algorithm)
@davidbgk
davidbgk / server.py
Created April 11, 2017 15:39
An attempt to create the simplest HTTP Hello world in Python3
import http.server
import socketserver
from http import HTTPStatus
class Handler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(HTTPStatus.OK)
self.end_headers()
self.wfile.write(b'Hello world')
@prideout
prideout / servewasm.py
Created November 8, 2018 00:44
Python WASM server
#!/usr/bin/env python3
import http.server
import socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
Handler.extensions_map.update({
'.wasm': 'application/wasm',
@optozorax
optozorax / random.cpp
Last active January 12, 2019 12:54
random by mt19937
#include <random>
double random(void) {
static std::mt19937 generator(time(0));
static std::uniform_real_distribution<double> distribution(0, 1);
return distribution(generator);
}