Skip to content

Instantly share code, notes, and snippets.

@kasajian
kasajian / powershell webserver.ps1
Last active October 23, 2020 08:51
powershell webserver
$Hso = New-Object Net.HttpListener
$Hso.Prefixes.Add("http://+:8000/")
$Hso.Start()
While ($Hso.IsListening) {
$HC = $Hso.GetContext()
$HRes = $HC.Response
$HRes.Headers.Add("Content-Type","text/plain")
$Buf = [Text.Encoding]::UTF8.GetBytes((GC (Join-Path $Pwd ($HC.Request).RawUrl)))
$HRes.ContentLength64 = $Buf.Length
$HRes.OutputStream.Write($Buf,0,$Buf.Length)
@kasajian
kasajian / recursive factorial through y-combinator.js
Last active October 23, 2020 08:55
recursive fatorial using y-combinator
var factorial = (f => {
return y => {
return f(y, f);
};
})((num, f) => {
return (num => {
if (num < 0) {
return -1;
} else if (num === 0) {
@kasajian
kasajian / reduxpattern.md
Last active July 4, 2016 17:59
The Redux Pattern

The whole state of your app is stored in an object tree inside a single store. The only way to change the state tree is to emit an action, an object describing what happened. To specify how the actions transform the state tree, you write pure reducers.

Three principles:

  1. Single source of truth. The state of your whole application is stored in an object tree within a single store.
@kasajian
kasajian / tryWinJs.html
Created January 8, 2016 20:03
WinJS Example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>tryWinJs</title>
<link href="winjs/css/ui-light.min.css" rel="stylesheet" />
<script src="winjs/js/base.min.js"></script>
<script src="winjs/js/ui.min.js"></script>
<style>
body{
@kasajian
kasajian / unlock and disconnect
Created September 16, 2015 17:27
unlock and disconnect from rdp session
tscon ((quser | ? {$_ -match 'intern' }) -split ' +')[1] /dest:console
(Source: http://superuser.com/questions/80334/remote-desktop-connection-without-locking-the-remote-computer)
@kasajian
kasajian / install rdp on ubuntu.txt
Last active October 23, 2020 08:55
install rdp on ubuntu.txt
$ sudo apt-get install ubuntu-desktop
$ sudo apt-get install xrdp
Then expose port 3389
sudo apt-get install xfce4
then modified the .xsession file in your home directory (if you dont have one, create it) and put the following line:
xfce-session
@kasajian
kasajian / mp4tomp3.bat
Created July 30, 2015 06:07
Windows cmd to convert mp4 to mp3 (extract audio) using ffmpeg
for %i in (*.mp4) do echo ffmpeg -i "%~ni.mp4" "%~ni.mp3"
@kasajian
kasajian / Example Table.md
Created July 9, 2014 21:08
Example Table
Tables Are Cool
col 3 is right-aligned $1600
col 2 is centered $12
zebra stripes are neat $1
@kasajian
kasajian / RDPUbunto12
Last active August 29, 2015 14:03
How to RDP into Ubuntu 12
Tested with VM running on Azure
sudo apt-get update
sudo apt-get install ubuntu-desktop
sudo apt-get install xrdp
sudo /etc/init.d/xrdp start
MAY NOT BE NEEDED:
echo gnome-session –session=Ubuntu-2d>~/.xsession
@kasajian
kasajian / Angular directive shows $comple.md
Last active August 29, 2015 14:01
shows how to repeat elements..

Very simple directive that will repeat a particular element a given number of times:

<div repeat-x="5">Hello</div>
// Directive to repeat an element x number of times
angular.module('app').directive('repeatX', [function () {
    return {