Skip to content

Instantly share code, notes, and snippets.

@soundsmitten
soundsmitten / Install.txt
Created July 15, 2019 02:37 — forked from soderlind/Install.txt
macOS DoH! (DNS over HTTPS) using cloudflared
1) Install cloudflared using homebrew:
brew install cloudflare/cloudflare/cloudflared
2) Create /usr/local/etc/cloudflared/config.yaml, with the following content
proxy-dns: true
proxy-dns-upstream:
- https://1.1.1.1/dns-query
- https://1.0.0.1/dns-query

Keybase proof

I hereby claim:

  • I am soundsmitten on github.
  • I am njlash (https://keybase.io/njlash) on keybase.
  • I have a public key whose fingerprint is 80C8 96A0 DBDB 120D ED97 C719 E99E 79CB E34C 6588

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am imightbewrong on github.
* I am njlash (https://keybase.io/njlash) on keybase.
* I have a public key whose fingerprint is 80C8 96A0 DBDB 120D ED97 C719 E99E 79CB E34C 6588
To claim this, I am signing this object:
@soundsmitten
soundsmitten / gist:ad44081981f54cd47b8c
Created May 28, 2014 18:00
Configuration.plist for Radicale Carddav
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>_className</key>
<string>PHXCardDAVSource</string>
<key>disabled</key>
<false/>
<key>homeInfo</key>
tell application "BBEdit" to set theFile to file of document 1
tell application "Finder" to set theFolder to (container of file theFile) as alias
set theUnixPath to POSIX path of theFolder
tell application "iTerm"
activate
set myTerm to (make new terminal)
tell myTerm
launch session "Default"
set _session to current session
end tell
@soundsmitten
soundsmitten / seguepass.mm
Created December 13, 2012 00:12
Objective-C: Example of Passing info from ViewController back to PreviousViewController
// AddViewController- has fields where data is entered.
AddViewController.h
@protocol AddDelegate <NSObject>
-(void) saveMySeconds: (int) seconds andTitle: (NSString*)activity;
@end
//AddViewController.m
#pragma mark text field delegate method
-(BOOL)textFieldShouldReturn:(UITextField *)textField { // dismiss keyboard on return.
[textField resignFirstResponder];
return YES;
@soundsmitten
soundsmitten / rss.mm
Created December 12, 2012 23:34
Objective-C Getting titles and descriptions in RSS feed
-(void) retrieveFromInternet {
NSURLRequest * request = [NSURLRequest requestWithURL: [self feedUrl]];
NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString * pageSource = [[NSString alloc] initWithData: data encoding:NSUTF8StringEncoding];
// NSLog(@"%@", pageSource);
[self setNewsStories: [self getHeadersAndSnippetsFromSource: pageSource]];
}
- (NSArray *) getHeadersAndSnippetsFromSource: (NSString *) pageSource {
NSArray * feedItems = [pageSource componentsSeparatedByString:@"<item>"];
NSMutableArray * titlesAndSnippets = [[NSMutableArray alloc]init];
@soundsmitten
soundsmitten / floyd.java
Created December 12, 2012 23:07
Java- Floyd's algorithm
// Wikipedia: a graph analysis algorithm for finding shortest paths in a weighted graph
// (with positive or negative edge weights) and also for finding transitive closure of a
// relation R. A single execution of the algorithm will find the lengths (summed weights)
// of the shortest paths between all pairs of vertices, though it does not return details
// of the paths themselves. The algorithm is an example of dynamic programming.
public void floyd(int n, int[][] W, int[][] P, int[][] D)
{
D = W;
for (int i = 0; i<n; i++)
@soundsmitten
soundsmitten / nQueens.java
Created December 12, 2012 22:59
Java- n-queens problem
// The eight queens puzzle is the problem of placing eight chess queens on an 8?8
// chessboard so that no two queens attack each other. Thus, a solution requires that no two
// queens share the same row, column, or diagonal. The eight queens puzzle is an example of the more general
// n-queens problem of placing n queens on an n?n chessboard,
// where solutions exist for all natural numbers n with the exception of 2 and 3.[
boolean promising (int i, int[] col) {
for (j=1; j<i; j++) {
if (col[i] == col[j]) {
return false;
}
@soundsmitten
soundsmitten / Dijkstra.java
Created December 12, 2012 22:41
Java- Dijkstra's algorithm
// From Wikipedia: For a given source vertex (node) in the graph, Dijkstra's algorithm finds the
// path with lowest cost (i.e. the shortest path) between that vertex and every other vertex.
void Dijkstra(int n, int [][] W, int source, int[] touch, int[] distance, int[totalCost])
{
int [] length
for(int i = 1; i<=n; i++)
{
touch[i] = source
length[i] = W[source][i]
}