Skip to content

Instantly share code, notes, and snippets.

@NeilRobbins
NeilRobbins / cloner.sh
Last active February 8, 2022 08:53
Clone all projects for a GitLab group
ORG=PUT_THE_ORG_NAME_HERE;ACCESS_TOKEN=PUT_THE_TOKEN_HERE; curl --header "PRIVATE-TOKEN: $ACCESS_TOKEN" "https://gitlab.com/api/v4/groups/$ORG/projects" | sed 's/,/\'$'\n''/g' | grep -e 'ssh_url_to_repo*' | cut -d \" -f 4 | xargs -L1 git clone
ORG=PUT_THE_ORG_NAME_HERE;PAGE=1;ACCESS_TOKEN=PUT_THE_TOKEN_HERE; curl "https://api.github.com/orgs/$ORG/repos?page=$PAGE&per_page=100&access_token=$ACCESS_TOKEN" | grep -e 'git_url*' | cut -d \" -f 4 | xargs -l1 git clone

Keybase proof

I hereby claim:

  • I am neilrobbins on github.
  • I am neilrobbins (https://keybase.io/neilrobbins) on keybase.
  • I have a public key ASAKOSp_oy9wgl97yNBGB_z6JigdNoyDV7-O183TUwD_wwo

To claim this, I am signing this object:

@NeilRobbins
NeilRobbins / params.sh
Created January 8, 2014 14:04
Some simple argument handling for use in shell scripts. HT to an answer on StackOverflow.
#! /bin/sh -
#argument defaults
x="foo"
y="bar"
# argument handling
while test $# -gt 0
do
case "$1" in
@NeilRobbins
NeilRobbins / TableCounts.sh
Last active January 2, 2016 12:09
List count of each vertica table in a schema (though regex could be used to match on properties other than the schema name).
vsql -e -w "PasswordHere" -c "\dt" | awk 'BEGIN { FS = "|" } $1 ~ /SchemaNameHere\>/ { for (i=1;i<=NF;i++) gsub (/(^ *)|(\W*$)/,"",$i); print "SELECT '\''" $1 "." $2 "'\'', COUNT(*) FROM " $1 "." $2 ";" }' | vsql -t -w "PasswordHere" | awk '/SchemaNameHere\>/ {print $1 "|" $3}'
@NeilRobbins
NeilRobbins / AntiForgerySessionDataProvider.cs
Created December 13, 2013 15:18
CSRF session linked protection with ASP.NET MVC
using System;
using System.Web;
using System.Web.Helpers;
namespace CSRF.Infrastructure
{
public class AntiForgerySessionDataProvider : IAntiForgeryAdditionalDataProvider
{
private readonly Func<string, string> _sessionKeyValuePair = sessionId => string.Format("Session: {0}", sessionId);
public string GetAdditionalData(HttpContextBase context)
@NeilRobbins
NeilRobbins / dumpgitlog
Created November 12, 2013 14:03
Dump the full git log to a text file with pretty-printed graph, and short date format
git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --graph --date=short > gitlog.txt
@NeilRobbins
NeilRobbins / Drop_unique_constraints_across_schemas.sql
Last active December 27, 2015 12:39
Drop all unique constraints from a named table, across all schemas with instances of that schema. Be aware that using the information_schema.table_constraints for schema names is not reliable and that sys.objects is preferred.
DECLARE @constraints_to_remove TABLE (
schemaName nvarchar(128) NOT NULL,
tableName sysname NOT NULL,
constraintName sysname NOT NULL);
INSERT @constraints_to_remove (
schemaName,
tableName,
constraintName)
SELECT
@NeilRobbins
NeilRobbins / LinesToQuotedCSV
Last active December 19, 2015 05:19
Take a file and make a csv from each line, trimming each line for excess whitespace, and placing its contents into double quotes. Use the uniq utility to remove any duplicate lines.
awk '{gsub (/^[ \t]+|[ \t]+$/,""); print "\"" $0 "\"," > "OUTPUT.csv" }' INPUT.txt
(defn foo
[arg]
(cond
(string? arg)
(println "a string")
(and (number? arg)
(pos? arg))
(println "pos arg yo!")