Skip to content

Instantly share code, notes, and snippets.

@nojaf
nojaf / alias.bat
Last active March 23, 2016 07:55
Windows cmd exe alias
doskey my-alias=my-app.exe $*
# doskey only works within the current session
# alternative is to make a bat file
"C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" %*
# %* means all arguments
@nojaf
nojaf / app.tsx
Last active April 25, 2016 14:36
minimal react router
let {Router, Route, Link, browserHistory, IndexRoute } = ReactRouter;
class HomePage extends React.Component<any,any> {
render(){
return <h1>Home</h1>
}
}
class AboutPage extends React.Component<any,any> {
render(){
@nojaf
nojaf / UnityConfig.cs
Created May 3, 2016 14:35
Unity config with Mediatr
using System;
using System.Linq;
using System.Reflection;
using MediatR;
using Microsoft.Practices.Unity;
namespace Project.Infrastructure
{
public static class UnityConfiguration
{
@nojaf
nojaf / write-args.ps1
Created August 3, 2016 11:03
Concatenate all arguments passed to PS script
Write-Output ([string]::Join("|", $args))
@nojaf
nojaf / commands.sh
Last active January 6, 2019 16:26
linux commands
# Nginx
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
sudo nginx -t
sudo service nginx restart
# MySQL
sudo mysql --user=myuser --password=mypassword mydb
# Find bash shell
echo $SHELL
@nojaf
nojaf / Program.cs
Created October 24, 2016 11:16
MainAsync
using System;
using System.Threading.Tasks;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
MainAsync(args).GetAwaiter().GetResult();
@nojaf
nojaf / export.sql
Created October 29, 2016 09:51
Export MySQL to csv
SELECT *
FROM my_table
INTO OUTFILE '/var/lib/mysql-files/myfile.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
@nojaf
nojaf / watchFile.js
Created November 14, 2016 10:28
Watch a file and run a command using nodejs
const {watch} = require("fs");
const {exec} = require("child_process");
watch("myFolder/myFile.ascx", (eventType,fileName) => {
if(eventType == "change"){
console.log("myFile.ascx changed");
exec('xcopy "Some Folder\\myFile.ascx" "Other Folder\\" /Y', () => {
console.log("File copied");
});
}
@nojaf
nojaf / Main.elm
Created November 21, 2016 12:18
Empty elm structure
import Html exposing (Html, div, text, program)
type alias Model =
String
init : ( Model, Cmd Msg )
init =
( "Hello", Cmd.none )
@nojaf
nojaf / Routing.elm
Last active December 2, 2016 12:41
import Dict exposing (Dict)
type Page
= NotFound
| LeaderBoardPage
| LoginPage
| RunnerPage
routes : Dict String Page
routes =