Skip to content

Instantly share code, notes, and snippets.

View snobu's full-sized avatar

Adrian Calinescu snobu

View GitHub Profile
@snobu
snobu / read_args.tcl
Last active February 1, 2017 22:15
Read command line arguments in TLC
puts "Script executed with $argc arguments"
set msg ""
foreach i $argv {
append msg $i
# Append comma if there's more than one argument
if {$i ne [lindex $argv $argc-1]} {
append msg ", "
}
}
@snobu
snobu / csharp-in-ps1.ps1
Created February 8, 2017 09:34
CSharp-in-PowerShell
$Source = @”
using System;
using System.IO;
namespace WillThisBlend
{
    public static class LetsSee
    {
        public static bool Check()
        {
@snobu
snobu / function.json
Last active February 19, 2017 13:33
FuncApp-DocDB-Binding
{
"bindings": [
{
"type": "eventHubTrigger",
"name": "myEventHubMessage",
"direction": "in",
"path": "marioevents",
"connection": "breakingnews"
},
{
# http://stackoverflow.com/a/39644735/4148708
tcpdump -ni eth0 "tcp port 443 and (tcp[((tcp[12] & 0xf0) >> 2)] = 0x16)"
@snobu
snobu / run.py
Last active March 2, 2017 14:30
temp-gist
from __future__ import absolute_import, unicode_literals
import sys, os, cStringIO, urllib, base64
import json
# Add function directory to import path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname( __file__ ))))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname( __file__ ), 'lib')))
from AzureHTTPHelper import HTTPHelper
http = HTTPHelper()
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
@snobu
snobu / MyStringExtensions.cs
Created March 8, 2017 13:35
.NET Truncate String
public static class MyStringExtensions
{
public static string Truncate(this string value, int maxLength)
{
if (string.IsNullOrEmpty(value)) return value;
return value.Length <= maxLength ? value : value.Substring(0, maxLength);
}
}
@snobu
snobu / gist:22d8cd9ceacc4db85e11dec6d9454c4e
Created March 31, 2017 09:27
Download and install Google Chrome from PowerShell
$LocalTempDir = $env:TEMP; $ChromeInstaller = "ChromeInstaller.exe"; (new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', "$LocalTempDir\$ChromeInstaller"); & "$LocalTempDir\$ChromeInstaller" /silent /install; $Process2Monitor = "ChromeInstaller"; Do { $ProcessesFound = Get-Process | ?{$Process2Monitor -contains $_.Name} | Select-Object -ExpandProperty Name; If ($ProcessesFound) { "Still running: $($ProcessesFound -join ', ')" | Write-Host; Start-Sleep -Seconds 2 } else { rm "$LocalTempDir\$ChromeInstaller" -ErrorAction SilentlyContinue -Verbose } } Until (!$ProcessesFound)
# Source:
# https://gist.github.com/kurokikaze/350fe1713591641b3b42
@snobu
snobu / web.config
Created April 10, 2017 05:55 — forked from KristofferBerge/web.config
Configuration file for Azure web app to support angular2 applications with routing and long urls for auth tokens.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<httpRuntime maxQueryStringLength="32768" maxUrlLength="65536"/>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxQueryString="32768"/>
</requestFiltering>
@snobu
snobu / string_interpolation.py
Created April 11, 2017 12:34
Python 2.7 string interpolation
cat = "CAT"
dog = "DOG"
# Python 2.6+
print "Molly wants a {cat} and a {dog}.".format(cat=cat, dog=dog)
# Molly wants a CAT and a DOG.
# below 2.6
print "Molly wants a %s and a %s." % (cat, dog)
# Molly wants a CAT and a DOG.