Skip to content

Instantly share code, notes, and snippets.

View einthusan's full-sized avatar

Einthusan Vigneswaran einthusan

  • Wojka Inc.
  • Toronto, Canada
View GitHub Profile
@einthusan
einthusan / errors-go2.go
Last active September 21, 2018 10:12
Go2 Error Aware Keywords - `return`, `defer`, `if`, and `!=` and forcing the error object to be the last argument
// THE GOAL of my proposal is to keep Go2 easy to read, which was it's number 1 strength.
// I am an ordinary programmer and therefore I don't know how difficult it will be to implement my proposal.
// I hope that Go2 can remain simple and easy to read.
// The syntax for Go error handling will ultimately rely on the changes to Go error types/values.
// If Go error handling syntax and Go error type is treated as 2 seperate topics,
// then Go2 errors as a whole will produce a solution that is not user friendly.
// the 'return' keyword only returns if the error != nil
// this means Go2's 'return' keyword will be aware of error types
// same as writing: if err != nil { return err }
@einthusan
einthusan / video-fix-videos-for-pseudo-streaming.md
Created November 30, 2016 23:16 — forked from alienresident/video-fix-videos-for-pseudo-streaming.md
How to: Fix pseudo-streaming videos by moving Moov Atom
How to:

Fix pseudo-streaming videos by moving Moov Atom

Relies on some *nix CLI utilities: mediainfo; and qt-faststart (part of ffmpeg). I used homebrew to install them on OS X.

What is pseudo-streaming?

Pseudo streaming is simply a video that can start playing before it's fully dowmloaded. The videos are not streaming but rather progressively downloaded. What's important is that the file metadata (the Moov Atom) is at the start of the file rather than at the end. Usually this is an option set when encoding the file (called quick start or web start). If the files have not been encoded this way you can either re-encode or use a utility to move the Moov Atom. Re-encoding takes much longer than using a utility to move the Moov Atom so here's how to do it.

Steps

First check with mediainfo to see if video 'is streamable':

@einthusan
einthusan / vpaidjs.xml
Created November 30, 2016 10:40
vpaidjs.xml
<VAST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vast.xsd" version="3.0">
<Ad id="1234567">
<InLine>
<AdSystem>GDFP</AdSystem>
<AdTitle>Linear VPAID</AdTitle>
<Description>Vpaid Linear Video Ad</Description>
<Error>http://www.example.com/error</Error>
<Impression>http://www.example.com/impression</Impression>
<Creatives>
<Creative sequence="1">
@einthusan
einthusan / gist:f83c0976eef50b5b2bb20450814cf21b
Created August 10, 2016 07:24 — forked from getify/gist:7240515
soft proposal: sessionStorage session-ID auto transmission as HTTP request header

In old-school web architecture (pre SPA's), we created a server-side session with an ID, then set a cookie with that session ID, so that each new page-request included the session-ID in it (to resume the session).

In new-school web archicture, where we do SPA's and we ditched cookies in favor of sessionStorage/localStorage, now we've lost a key part of that interaction paradigm: the session-ID can be stored in sessionStorage and used by the SPA to render session-aware pages, and we can even send that session-ID along with any subsequent Ajax/WebSockets messages to the server... BUT we cannot, currently, have that sessionStorage-stored session-ID automatically transmitted with each normal page request.

This means that the initial page-response from the server, even in the case where someone has a valid session, must be session-unaware, and the SPA code on the client side must update the page with session-aware info "later", since the session-ID on the client wasn't provided with the initial HTTP request like

@einthusan
einthusan / remove-message.js
Created March 5, 2016 02:07 — forked from simonw/remove-message.js
JavaScript one-liner for removing a ?message=... parameter from the visible URL in the browser
history.replaceState && history.replaceState(
null, '', location.pathname + location.search.replace(/[\?&]message=[^&]+/, '').replace(/^&/, '?')
);
@einthusan
einthusan / clean nodejs
Created November 13, 2015 08:49
cleaning nodejs
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : ssh.go
* Purpose :
* Creation Date : 11-18-2013
* Last Modified : Thu Dec 5 23:12:09 2013
@einthusan
einthusan / go_scp.go
Last active August 29, 2015 14:14 — forked from jedy/go_scp.go
// https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works
package main
import (
"code.google.com/p/go.crypto/ssh"
"crypto"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
@einthusan
einthusan / go1.4arc65-ubuntu.sh
Last active July 10, 2018 23:43
Install Golang 1.4.1 on Ubuntu 14.04 AWS EC2
#!/bin/sh
# OPTIONAL FLAGS:
#
# -geoip true
# this will install maxmind geoip and auto update crontab file
#
# -cloudwatch true
# this will install aws cloud watch metrics and send them to aws dashboard
#
@einthusan
einthusan / removesvn
Last active August 29, 2015 14:06 — forked from djadriano/gist:5041994
Find and remove svn files
// find .svn files
find . -type d -name .svn
// remove .svn files
rm -rf `find . -type d -name .svn`