Skip to content

Instantly share code, notes, and snippets.

Avatar

Boy Baukema relaxnow

View GitHub Profile
View categories-to-csv.go
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
)
@relaxnow
relaxnow / config.yml
Last active May 4, 2021
Ibuildings NelmioSecurityBundle recommended configuration
View config.yml
nelmio_security:
# don't use signed cookies
# don't use encrypted cookies
# prevent framing of the entire site
clickjacking:
paths:
'^/.*': DENY
# prevent redirections outside the website's domain
external_redirects:
abort: true
@relaxnow
relaxnow / longest-common-substring.php
Created Oct 10, 2011
Longest Common Substring algorithm in PHP
View longest-common-substring.php
<?php
function getLongestCommonSubstring($first, $second)
{
$longestCommonSubstringIndexInFirst = 0;
$table = array();
$largestFound = 0;
$firstLength = strlen($first);
$secondLength = strlen($second);
View brute-force-chances.js
/**
* Bit of code you can run in your developer toolbar or on https://jsfiddle.net .
*
* Fill in the characteristics of your own 'public file' solution and acceptance criteria.
*/
(function(){
'use strict';
// dec=10,hex=16,[A-Z0-9]=36, etc.
var CHARACTER_COMBINATIONS = 16,
View validation-with-java-example
if (val < 0 || val > 19) {
System.out.println("please read the instructions again");
System.exit(0);
}
View example.sh
#!/bin/sh
echo "Hello World!"
View stupid.sh
#!/bin/bash
while [ true ];
do
say "I am stupid"
SLEEPTIME=`jot -r 1 1 10`
sleep $SLEEPTIME
done
View janus-api-test.sh
#!/bin/sh
getConnection ()
{
curl -v -k -u engine:engineblock -H "Content-Type: application/json" -X GET https://serviceregistry.demo.openconext.org/janus/app_dev.php/api/connections/15.json
}
jqModify ()
{
# jq 'def key_contains: .key | contains(":sn") | not ; def filter_key(f): f | to_entries | map(select(key_contains)) | from_entries ; .arpAttributes = filter_key(.arpAttributes)'
View deduplicate.php
<?php
if (!isset($argv[1])) {
die('Usage: deduplicate.php "Dropbox/Camera Uploads/2014"' . PHP_EOL);
}
$path = $argv[1];
if (!is_dir($path)) {
die("$path is not a dir!" . PHP_EOL);
}