Skip to content

Instantly share code, notes, and snippets.

@munho
munho / install_all_pods.sh
Created August 29, 2017 02:22
for $dirs install all pods.sh
dirs=$(find . -name Podfile -print0 | xargs -0 -n1 dirname | sort --unique)
top=$(pwd)
for dir in $dirs
do
cd "$dir"
pod install
cd "$top"
done
@munho
munho / customimage.m
Created January 3, 2018 02:58 — forked from vuraltuna/customimage.m
Using a custom image for a UITableViewCell's accessoryView a
// *********** Using a custom image for a UITableViewCell's accessoryView and having it respond to UITableViewDelegate
UIImage *image = [UIImage imageNamed:@"MenuSectionHeaderArrow.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
button.frame = frame; // match the button's size with the image size
[button setBackgroundImage:image forState:UIControlStateNormal];
// set the button's target to this table view controller so we can interpret touch events and map that to a NSIndexSet
@munho
munho / TimerWithGCD.md
Created January 8, 2018 09:13
Creating a timer with Grand Central Dispatch

##Creating a timer with Grand Central Dispatch

At the following is the implementation file of a sample class that shows, how to make a timer with the help of Grand Central Dispatch. The timer fires on a global queue, just change the queue to the main queue or any custom queue and the timer fires on this queue and not on the global queue anymore.

#import <Foundation/Foundation.h>

@interface SampleClass : NSObject
- (void)startTimer;
@munho
munho / uart.c
Created February 1, 2018 05:03 — forked from ryankurte/uart.c
Simple unix serial implementation. This uses pthreads to receive and buffer incoming data for later use.
#include "uart.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <termios.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@munho
munho / update_git_repos.sh
Created March 18, 2018 02:12 — forked from douglas/update_git_repos.sh
Update all git repositories under a base directory
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
@munho
munho / sudoku.py
Created May 17, 2018 23:43 — forked from jkk/sudoku.py
## Solve Every Sudoku Puzzle
## See http://norvig.com/sudoku.html
## Throughout this program we have:
## r is a row, e.g. 'A'
## c is a column, e.g. '3'
## s is a square, e.g. 'A3'
## d is a digit, e.g. '9'
## u is a unit, e.g. ['A1','B1','C1','D1','E1','F1','G1','H1','I1']
@munho
munho / AppDelegate10.m
Created June 1, 2018 02:37 — forked from jzucker2/AppDelegate10.m
UserNotifications on iOS 10
// Make sure to include this at the top of AppDelegate.m
@import UserNotifications;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Check Notification Settings on launch
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
switch (settings.authorizationStatus) {
// This means we have not yet asked for notification permissions
case UNAuthorizationStatusNotDetermined:
@munho
munho / ComPort over Network.md
Created July 10, 2018 07:48 — forked from DraTeots/ComPort over Network.md
ComPort over Network

Connecting to serial port (com port) over network

(Serial port or com port? - Serial ports are often refered as COM ports. It is the same to be short. You can read abut it in the Wiki article )


## The problem Suppose we have an application that works with some device using serial port (com port). It could be GPS reader, IRDA, whatever. So it looks like this:
# -*- coding: utf-8 -*-
import sys
import threading
import queue
# from kivy.compat import queue
import serial
import time
import kivy
kivy.require('1.9.0')
@munho
munho / SimpleHTTPServerWithUpload.py
Created January 7, 2019 22:37 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""