Skip to content

Instantly share code, notes, and snippets.

@perifer
perifer / pre-push
Created December 29, 2022 12:42
Branching policy
#!/usr/bin/env bash
LC_ALL=C
local_branch="$(git rev-parse --abbrev-ref HEAD)"
valid_branch_regex="^(feature|bugfix|release|hotfix|archive)\/[a-z0-9._-]+$"
message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. You should rename your branch to a valid name and try again."
if [[ ! $local_branch =~ $valid_branch_regex ]]
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/kml/2.2 http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd">
<Document xmlns:atom="http://purl.org/atom/ns#">
<name>grundvatten:SE.GOV.SGU.BRUNNAR.250K</name>
<Placemark id="SE.GOV.SGU.BRUNNAR.250K.fid--1d29464a_1382ef57918_344c">
<name><![CDATA[SE.GOV.SGU.BRUNNAR.250K.fid--1d29464a_1382ef57918_344c]]></name>
<description><![CDATA[<h4>SE.GOV.SGU.BRUNNAR.250K</h4>
<ul class="textattributes">
<li><strong><span class="atr-name">Brunns-ID</span>:</strong> <span class="atr-value">106400441</span></li>
@perifer
perifer / gist:99ff0307181967107e26
Last active August 29, 2015 14:19
API example
{
"title": "Civilingenjör i datorsäkerhet",
"sections": {
"overview": {
"title": "Översikt",
"subSections": {
"profile": {
"header": "Profil - innehåll",
"content": "<p>Den här utbildningen ger dig en stabil grund inom datakunskap och en unik spetskompetens inom datorsäkerhet så att du kan förebygga, upptäcka och åtgärda såväl tekniska problem som kriminalitet.</p><p>Kanske kommer du att arbeta på Statens kriminaltekniska laboratorium med att analysera IT-bevismaterial, på Ericsson med utveckling av programvara eller vid Säkerhetspolisen. Du kan jobba som säkerhetschef eller säkerhetskonsult i Sverige eller utomlands.</p><p>Programmet ger dig grunderna du behöver i datorsystemteknik, programmering och matematik. På kurserna i datorsäkerhet söker du digitala bevis med forensisk datoranalys, studerar nätverkssäkerhet, knäcker lösenord och lär dig hitta spår av intrångsförsök. Projektarbete på företag och gästföreläsningar ger dig nya perspektiv och inspirerar till
#!/usr/bin/env bash
chmod_files()
{
for file in "$1"/*; do
[[ ! -d $file ]] && chmod +x "$file"
done
}
@perifer
perifer / gist:fde4f6827e4e9417a9c9
Last active August 29, 2015 14:02
Asynchronous Javascript Action
// Adopted from
// http://www.obdev.at/resources/launchbar/developer-documentation/javascript-http.html#//apple_ref/cpp/Method/getJSON
function run(done) {
var search = 'perfect circle';
var query = encodeURIComponent(search);
var result = HTTP.getJSON('http://ws.spotify.com/search/1/artist.json?q=' + query, function(result) {
if (result.data != undefined) {
// Show the top result:
var artist = result.data.artists[0];
done([{ 'title' : artist.name}]);
@perifer
perifer / bitbucket-origin-all.sh
Created October 22, 2013 06:12
Change the origin remote url from github to bitbucket for all git repos inside the current folder and 3 levels down
# Change the origin remote url from github to bitbucket
# for all git repos inside the current folder and 3 levels down
CURRENT=`pwd`
for DIR in $(find . -name ".git" -type d -maxdepth 3)
do
cd "$DIR"
cd ..
OLDORIGIN=`git config --get remote.origin.url`
@perifer
perifer / gist:5488903
Last active December 16, 2015 19:59
go keys

go keys

security feautures

Each client holds a secret. The secret is used as passphrase for the keys (or only one key?) on the master.

The secret is also used to create a hmac that validates that the data stored in db.json has not been tampered with. This is done by created an hmac of the data in db.json and the secret. The hmac is saved in db.json alongside with the data. Next requset to the server from a client the hmac is recreated and matched against the stored hmac to verify that the data is not changed.

go keys

go keys server

go keys server add NAME --user SERVER_USER --hostname HOSTNAME --url SERVER_URL --tags "TAG1,TAG2,TAG3" --repo REPO_URL --description "A DESCRIPTION" (other options)

--tags: coma or space seperated

go keys server edit (same options as add)

@perifer
perifer / track.js
Created March 2, 2013 08:27
Track virtual page views in Google Analytics if (window._gaq) { window._gaq.push(['_trackPageview', window.location.pathname + href]); }
if (window._gaq) {
window._gaq.push(['_trackPageview', href]);
}
@perifer
perifer / gist:3952349
Created October 25, 2012 12:42
Improved web font loader code to prevent FOUT
// Custom web font loader inspired by the TypeKit loader.
WebFontConfig = {
fontdeck: {
id: FONTDECK_ID
},
active: function() {
clearTimeout(this._timeout);
}
};
(function() {