Skip to content

Instantly share code, notes, and snippets.

@tcshao
tcshao / replaceNumbers.ps1
Last active October 11, 2015 02:48
Simple powershell loop and replace
<# Loop through IRC log File #>
$quotes = @()
$dest = 'out.txt'
Get-Content in.txt | % {
$line = $_ -replace '.*?[0-9]:',''
$line = $line -replace '"',''
$quotes += $line
}
@tcshao
tcshao / DeleteOldTextFiles.ps1
Last active October 11, 2015 03:38
Deleting *.txt files from 'c:\temp' and subdirectories more than 5 days old
<# Deleting *.txt files from 'c:\temp' and subdirectories more than 5 days old #>
Get-ChildItem 'C:/temp' -Recurse -Include '*txt'
| WHERE { ($_.CreationTime -le $(Get-Date).AddDays(-5)) }
| Remove-Item
@tcshao
tcshao / DataSeries.cs
Last active October 11, 2015 09:48
feeding a dynamic interpolation function to a series
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Numerical
{
public class DataSeries
{
public List<double> X { get; set; }
@tcshao
tcshao / FizzBuzz.fsx
Last active April 27, 2019 10:52
FizzBuzz in F#
let fizzBuzz x =
match x with
| _ when (x % 15) = 0 -> "FizzBuzz"
| _ when (x % 3) = 0 -> "Fizz"
| _ when (x % 5) = 0 -> "Buzz"
| _ -> ""
let fizzBuzzTo max =
[1..max]
|> List.iter (fun number -> printfn "%d %s" number (fizzBuzz number))
@tcshao
tcshao / sessions_helper.rb
Last active December 17, 2015 12:49
From Rails tutorial Chapter 8 step. The existing sessions_helper does not work.
module SessionsHelper
def sign_in(user)
cookies.permanent[:remember_token] = user.remember_token
self.current_user = user
end
def current_user=(user)
@current_user = user
end
@tcshao
tcshao / installrailstutorial.sh
Created May 21, 2013 05:00
Commands required to start up a Ubuntu Server 13.04
#!/bin/bash
apt-get update -y
apt-get upgrade -y
apt-get install ruby1.9.1 - y
apt-get install ruby1.9.1-dev -y
apt-get install build-essential -y
apt-get install libsqlite3-dev -y
apt-get install nodejs -y
apt-get install git -y
apt-get install libxslt-dev -y
class Workflow
def process
you_should_do_this_first
then_you_should_do_this
this_will_be_done_last
end
end
class Headhunter < Workflow
@tcshao
tcshao / regex.rb
Last active December 19, 2015 00:59
filename = "03hardcore.mp3"
pattern1 = /
\d\d # first two are numbers
.ardcore
\. # a dot
mp\d # mpx file
/x
puts pattern1 =~ filename # this returns 0 (match)
# loaded via curl -fsSL [this RAW url] | sudo sh
dconf write /org/compiz/profiles/unity/plugins/unityshell/icon-size 30
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize 2
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ vsize 2
sudo apt-add-repository ppa:andrei-pozolotin/maven3
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install -y zsh git maven3
#Add $JAVA_HOME path to exports
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
{
"extends": "tslint:all",
"rules": {
"object-literal-sort-keys": false,
"ordered-imports": false,
"member-ordering": [
false
],
"member-access": [
false