Skip to content

Instantly share code, notes, and snippets.

View surma's full-sized avatar
🍑

Surma surma

🍑
View GitHub Profile
#!/bin/bash
HOSTNAME=$(curl -s http://metadata/computeMetadata/v1beta1/instance/hostname | cut -d '.' -f 1)
APIKEY=$(curl -s http://metadata/computeMetadata/v1beta1/project/attributes/dnsimpleDomainToken)
DOMAIN=$(curl -s http://metadata/computeMetadata/v1beta1/project/attributes/dnsimpleDomain)
IP=$(curl -s http://metadata/computeMetadata/v1beta1/instance/network-interfaces/0/access-configs/0/external-ip)
if [ $(curl -s -X GET -H "X-DNSimple-Domain-Token: $APIKEY" -H "Accept: application/json" "https://dnsimple.com/domains/$DOMAIN/records?type=A" | grep $HOSTNAME | wc -l) -eq 0 ]; then
echo "Creating new record..."
curl -s -X POST -H "X-DNSimple-Domain-Token: $APIKEY" -H "Accept: application/json" -H "Content-Type: application/json" -d "{\"record\":{\"name\":\"$HOSTNAME\",\"record_type\": \"A\", \"content\": \"$IP\", \"ttl\": 60}}" "https://dnsimple.com/domains/$DOMAIN/records"
@surma
surma / test.nim
Last active August 29, 2015 13:56
type
TMsg = object
data : string
var
c : TChannel[TMsg]
t : TThread[void]
proc logger(){.thread.} =
echo("Logger start")
[
{
"name": "campact",
"authentication_type": "OAuth2",
"authentication_endpoints": {
"auth_url": "http://auth.c3k.localtest.me:8000/oauth2/authorize",
"token_url": "http://auth.c3k.localtest.me:8000/oauth2/token",
"scope": "user"
},
"data_endpoints": [
@surma
surma / gist:11010849
Last active August 29, 2015 14:00
Serien Junkies extractor
x=[]; t=$0.nextSibling; while(t && (t.className || "") == "") {if(t.nodeName == "P"){x.push(t.querySelector(".download_main > a").href);};t=t.nextSibling}; x.join("\n")
@surma
surma / ruprecht_remover.js
Last active August 29, 2015 14:09
Fuck Rup Recht
window.setInterval(function() {
$("div.fbChatSidebar ul li:contains('Rup Recht')[data-id]").hide()
}, 1000)

Keybase proof

I hereby claim:

  • I am surma on github.
  • I am surma (https://keybase.io/surma) on keybase.
  • I have a public key whose fingerprint is 6502 0FBD ECB4 9DFF 48F6 C244 DF43 AB40 0F58 C405

To claim this, I am signing this object:

@surma
surma / list.go
Created June 21, 2011 12:43
Unexpected behaviour of go linker?
package list
var List map[string]string = make(map[string]string)
@surma
surma / loop.php
Created August 7, 2011 19:00
Peter's Liste
<!-- SNIP -->
<ul id="sources" class="meta_categories">
<?php
function getFormattedCategory($category, $show_count) {
$link = get_category_link($category->term_id);
$result = "<a href=\"".$link."\">".$category->name."</a>";
if($show_count) {
$result .= "(".$category->count.")";
}
if($category->category_description != "") {
@surma
surma / .bash_profile
Created September 14, 2011 10:32
Bash Prompt Code
# Colors
COLOR_WHITE='\033[1;37m'
COLOR_LIGHTGRAY='\033[0;37m'
COLOR_GRAY='\033[1;30m'
COLOR_BLACK='\033[0;30m'
COLOR_RED='\033[0;31m'
COLOR_LIGHTRED='\033[1;31m'
COLOR_GREEN='\033[0;32m'
COLOR_LIGHTGREEN='\033[1;32m'
COLOR_BROWN='\033[0;33m'
#if UNITY_EDITOR
private static void _init(string AppId) {}
private static void _authorize(int permissions) {getInstance().loggedOut();}
private static void _logout() {getInstance().loggedOut();}
private static void _graphRequest(string methodname, string[] param, string method) {getInstance().requestFailed("Not implemented");}
private static void _deleteSession() {}
#elif UNITY_IPHONE
[System.Runtime.InteropServices.DllImport("__Internal")]
extern static private void _init(string AppId);
[System.Runtime.InteropServices.DllImport("__Internal")]