Skip to content

Instantly share code, notes, and snippets.

View daijo's full-sized avatar

Daniel Hjort/SA7DAI daijo

  • Billeberga, Sweden
View GitHub Profile
@daijo
daijo / gist:9776579
Created March 26, 2014 03:37
Mac CLI
# Show/hide hidden files
defaults write com.apple.finder AppleShowAllFiles TRUE;killall Finder
defaults write com.apple.finder AppleShowAllFiles FALSE;killall Finder
@daijo
daijo / scrabble.sh
Created January 23, 2013 09:08
Prints all lines that only contains the given letters.
#!/bin/bash
# Prints all lines that only contains the given letters.
# Matching is case insensitive.
#
# usage: scrabble.sh FILE ABC
DICTIONARY_FILE=$1
CHARS_TO_USE=`echo $2 | tr '[a-z]' '[A-Z]'`
ALPHABET="ABCDEFGHIJKLMNOPQRSTUVXYZ"
FORBIDDEN_CHARS=`echo ${ALPHABET//[$CHARS_TO_USE]/}`
@daijo
daijo / busy-tail-android
Created September 26, 2012 03:34
Busy pulling a log file and tailing it from an Android device.
#!/bin/bash
while true; do
adb pull $1
filename=$(basename $1)
tail -50 $filename
sleep 2
done
@daijo
daijo / UIWebView+Markdown.m
Created September 2, 2011 02:08
UIWebView+Markdown category.
//
// UIWebView+Markdown.m
// DropTextwiki
//
// Created by Daniel Hjort on 6/5/11.
// Copyright 2011 Patchwork Solutions AB. All rights reserved.
//
#import "UIWebView+Markdown.h"
#import "html.h"
@daijo
daijo / basic_auth_snippet.m
Created September 2, 2011 01:21
Add basic auth credential for a NSURLConnection.
NSURLCredentialStorage *sharedCredentials = [NSURLCredentialStorage sharedCredentialStorage];
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"user" password:@"pwd" persistence:NSURLCredentialPersistencePermanent];
NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc] initWithHost:@"my.gtdify.com" port:80 protocol:@"http" realm:nil authenticationMethod:NSURLAuthenticationMethodHTTPBasic] autorelease];
[sharedCredentials setCredential:credential forProtectionSpace:protectionSpace];