Skip to content

Instantly share code, notes, and snippets.

@kasajian
kasajian / ApprovalTests.cpp
Last active October 23, 2020 08:21
Approval Tests CPP
#include "ApprovalTests.hpp"
#include <iostream>
void TestXyz()
{
try
{
TestName currentTest;
currentTest.setFileName(__FILE__);
currentTest.sections = { "TestXyz" };
@kasajian
kasajian / ValueObject.cs
Last active October 23, 2020 08:29
ValueObject
public class ConnectionString
{
public string Value { get; private set; }
public ConnectionString(string value)
{
Value = value;
}
public static implicit operator string(ConnectionString connectionString)
@kasajian
kasajian / m.c
Created October 5, 2017 20:27
ASCII image of the Mandelbrot set
main (n)
{
float r, i, R, I, b;
for (i = -1; i < 1; i += .06, puts (""))
for (r = -2; I = i, (R = r) < 1; r += .03, putchar (n + 31))
for (n = 0; b = I * I, 26 > n++ && R * R + b < 4;
I = 2 * R * I + i, R = R * R - b + r);
}
@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"