Skip to content

Instantly share code, notes, and snippets.

View kasperhartwich's full-sized avatar

Kasper Hartwich kasperhartwich

View GitHub Profile
[user]
name = Kasper Hartwich
email = kasperhartwich@gmail.com
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
@kasperhartwich
kasperhartwich / RectangleConfig.json
Created February 2, 2023 07:44
My Rectangle configuration to mimic the hotkeys of Magnet
{
"bundleId" : "com.knollsoft.Rectangle",
"defaults" : {
"allowAnyShortcut" : {
"bool" : false
},
"almostMaximizeHeight" : {
"float" : 0
},
"almostMaximizeWidth" : {
@kasperhartwich
kasperhartwich / TorProxy.php
Created October 12, 2020 12:20
Check to see if ip address comes from a Tor proxy
<?php
class TorProxy
{
/**
* Is IP address a Tor proxy ip address.
* See https://lists.torproject.org/pipermail/tor-project/2020-March/002759.html
*
* @param $ip
* @return bool
*/
@kasperhartwich
kasperhartwich / replace-text-in-dirs
Created April 15, 2020 07:44
Command to replace text in all f.ex. php files in directory
# OSX
find . -name '*.php' -print0 | xargs -0 sed -i "" "s/TextToReplace/NewText/g"
@kasperhartwich
kasperhartwich / install-mssql.sh
Last active March 5, 2020 05:49
Install MSSQL server on vagrant with ubuntu/homestead
#!/usr/bin/expect -f
# This installs MSSQL server and drivers on a vagrant ubuntu machine
#
# To use you need to install expect: `sudo apt-get install -y expect`
# and then run the script with the password you want: install-mssql.sh myPass123
# Then log in to the sql server with username `sa`and the password `myPass123`
set password [lindex $argv 0]
#Add MSSQL to package manger
@kasperhartwich
kasperhartwich / AppDate.php
Created July 16, 2017 06:48
Fixes a bug with diffInMonths for DateTime/Carbon
<?php
use Carbon\Carbon;
/**
* This fixes the bug in DateTime with diffInMonths!
* See this bugreport: https://github.com/briannesbitt/Carbon/issues/344
*/
class AppDate extends Carbon
{
/**
@kasperhartwich
kasperhartwich / artisan-alias
Created February 3, 2017 15:05
Never write `php artisan`again
echo 'alias artisan="php artisan"' >>~/.bash_profile
@kasperhartwich
kasperhartwich / doorbell.cpp
Created May 20, 2016 22:02
Small program to trigger a IFTTT event with a button on a Particle.io Photon
/**
* Simple doorbell to IFTTT program for Particle.io Photon
* - Connect the button to GND and D0.
* - Connect your particle.io account to IFTTT and setup a trigger for 'ring'
*/
int button = D0;
void setup() {
pinMode(button, INPUT_PULLUP);
@kasperhartwich
kasperhartwich / delete-from-slack.php
Last active January 26, 2021 08:10
Script to delete old files from Slack
#!/usr/bin/env php
<?php
date_default_timezone_set('GMT');
if (count($argv)<2) {
echo $argv[0] . ' <token> <until>' . PHP_EOL;
echo 'Example: ' . $argv[0] . ' abcd-12345678-123456789-12345 \'-3 months\'' . PHP_EOL;
exit;
}
@kasperhartwich
kasperhartwich / hdhomerun-vlc.bat
Created October 19, 2014 20:43
Channelchanger (windows) for HDHomerun found somewhere on the internet..
@echo off
REM Select Channel and Program
set /p _channel=Please enter channel:
set /p _pro=Please enter program:
REM Get your IP address
for /f "delims=[] tokens=2" %%a in ('ping -4 %computername% -n 1 ^| findstr "["') do (set thisip=%%a)
set "str1=udp://"