Skip to content

Instantly share code, notes, and snippets.

View nilsou's full-sized avatar

Nils Hayat nilsou

View GitHub Profile
@nilsou
nilsou / Installation.md
Last active February 21, 2023 19:25 — forked from albertbori/Installation.md
Automatically disable Wifi when an Ethernet connection (cable) is plugged in on a Mac

Overview

This is a bash script that will automatically turn your wifi off if you connect your computer to an ethernet connection and turn wifi back on when you unplug your ethernet cable/adapter. If you decide to turn wifi on for whatever reason, it will remember that choice. This was improvised from this mac hint to work with Yosemite, and without hard-coding the adapter names. It's supposed to support growl, but I didn't check that part. I did, however, add OSX notification center support. Feel free to fork and fix any issues you encounter.

Most the credit for these changes go to Dave Holland.

Requirements

  • Mac OSX 10+
  • Administrator privileges
@nilsou
nilsou / array_partition.c
Created October 14, 2013 02:57
Array Partition of equal sum possible? http://www.careercup.com/question?id=8879649
#include <stdlib.h>
#include <stdio.h>
int compare_function(const void *a,const void *b) {
int *x = (int *) a;
int *y = (int *) b;
return *x - *y;
}
int array_partition_possible(int *array, int count) { //array needs to be already sorted
#include <stdlib.h>
#include <stdio.h>
typedef struct solution {
int start;
int end;
int sum;
} solution;
int sum_array(int *array, int count) {
@nilsou
nilsou / edit-distance.c
Last active December 25, 2015 10:49
Edit Distance between strings in C. http://basicalgos.blogspot.com/search/label/facebook
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
static inline unsigned int
min(unsigned int a, unsigned int b, unsigned int c)
{
unsigned int m = a;
if (m > b) m = b;
if (m > c) m = c;
@nilsou
nilsou / view-xcode-5.xib
Created July 22, 2013 20:40
What Xib files look like in XCode 5
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4471.1" systemVersion="12E55" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment defaultVersion="1552" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3697.3"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="1">
@nilsou
nilsou / view-xcode-4.xib
Last active December 20, 2015 02:39
What Xib files look like in XCode 4
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1552</int>
<string key="IBDocument.SystemVersion">12E55</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.39</string>
<string key="IBDocument.HIToolboxVersion">626.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>