Skip to content

Instantly share code, notes, and snippets.

View joedborg's full-sized avatar
🏠
Working from home

Joe Borg joedborg

🏠
Working from home
View GitHub Profile
@joedborg
joedborg / post.go
Created October 10, 2014 17:48
Example of a POST handle in Go
package main
import (
"fmt"
"net/http"
)
var form = []string{
"Make",
"Model",
@joedborg
joedborg / post_to_sms.go
Created October 10, 2014 18:47
Example of a POST handle in Go that uses Twilio to SMS the form
package main
import (
"fmt"
twilio "github.com/carlosdp/twiliogo"
"net/http"
"strings"
)
var form = []string{
@joedborg
joedborg / gist:c8613a671cd312aee505
Last active August 29, 2015 14:23
How old am I?
import math
from datetime import datetime
def how_old_am_i(year, month, day):
"""
Get how old you are in years.
:param year: Integer year born
:param month: Integer month born
:param day: Integer day born
:retuns: Integer years old
@joedborg
joedborg / polldaddy.rb
Last active January 2, 2016 12:59 — forked from kingbin/polldaddy.rb
require 'open-uri'
pollNumber = '5876349'
ourPick = '26523547'
uriString = 'http://polldaddy.com/n/64270c358614e8ef9383968590e82f73/'.concat(pollNumber).concat('?').concat(Time.now.to_i.to_s())
puts uriString
# Headers
HEADERS = {
'Host' => 'polldaddy.com',
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7',
@joedborg
joedborg / is_seq_in_list.py
Created October 28, 2016 14:46
Look for a sequuence within a list
def is_seq_in_list(sequence, match):
for i, j in enumerate(sequence):
if sequence[i:len(match) + i] == match:
return True
return False
if __name__ == '__main__':
match = [1, 3, 4]
sequence = [2, 3, 6, 3, 8, 1, 3, 4, 8, 2]
is_seq_in_list(sequence, match)
git:
source: https://github.com/git/git
source-type: git
source-depth: 1
plugin: autotools
configflags:
- --with-curl
- --with-expat
build-packages:
- gettext
import subprocess
from typing import List
def get_packages() -> List[str]:
out: str = subprocess.check_output(['pip', 'freeze']).decode()
packages: List[str] = out.split('\n')
return [x.split('==')[0] for x in packages]
@joedborg
joedborg / multipass-charm.yaml
Last active April 15, 2019 15:48
cloud-init configuration for Charm development
# cloud-config
## launch multipass instance with `--cloud-init [this file]`
## then mount your charm workspace with `multipass mount "." "[instance name]:/project"`
write_files:
- path: /etc/profile.d/charm-dev.sh
permissions: "0644"
content: |
export CHARM_BUILD_DIR=/builds
export CHARM_LAYERS_DIR=/layers
@joedborg
joedborg / crictl_install.py
Created April 24, 2019 15:01
crictl Charm Installation
@when('config.changed.crictl-version')
def crictl_version_changed():
"""
crictl version has changed.
:return: None
"""
remove_state('crictl.installed')
@joedborg
joedborg / gist:d9aa478c72c9f374bdf5217854419da2
Last active March 24, 2020 14:52
Getting AutoRun registry key
import winreg
cmd = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Command Processor', access=winreg.KEY_WRITE)
winreg.SetValueEx(cmd, 'AutoRun', 0, winreg.REG_SZ, 'myscript.bat')