Skip to content

Instantly share code, notes, and snippets.

View mchirico's full-sized avatar
💭
Kubernetes... API Server Development

Mike Chirico mchirico

💭
Kubernetes... API Server Development
View GitHub Profile
@mchirico
mchirico / dismiss
Created March 11, 2012 12:05
Common way to dismiss Modal View Controller
- (IBAction)buttonBack:(id)sender {
[[self presentingViewController] dismissModalViewControllerAnimated:YES];
}
@mchirico
mchirico / prepareForSegue
Created March 11, 2012 12:19
prepareForSegue Template
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier hasPrefix:@"Create Label"]) {
AskerViewController *asker = (AskerViewController *)segue.destinationViewController;
asker.question = @"What";
asker.delegate = self;
}
// This is really cool.
if ([segue.identifier hasPrefix:@"Segue Table0"]) {
@mchirico
mchirico / CmdTdev.java
Last active December 11, 2015 09:28
The following is an example of the ExecutorService to make system calls.
package dev.sysadmin.test;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class CmdTdev {
private static int myid;
@mchirico
mchirico / gist:4582368
Created January 20, 2013 22:52
Command to allow eclipse to run on the Mac
xattr -d com.apple.quarantine /path/to/Eclipse.app
@mchirico
mchirico / MenuLookDemo.java
Last active December 11, 2015 11:48
Oracle's menu demo with a few events. The trail can be found here: http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html Make sure you use frame.validate() to correctly display the frame.
package dev.sysadmin.test;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JButton;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JRadioButtonMenuItem;
@mchirico
mchirico / myiter.java
Created January 29, 2013 15:53
Example iterator with HashMap
public void pr(ConcurrentHashMap<String, String[][]> hmap) {
Iterator itr = hmap.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry pairs = (Map.Entry) itr.next();
System.out.println("key= " + pairs.getKey());
pr((String[][]) pairs.getValue());
// itr.remove(); // avoids a ConcurrentModificationException
}
}
@mchirico
mchirico / FileRead.java
Created January 29, 2013 16:47
Example FileRead in java
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class FileRead {
public String[] readLines(String filename) throws IOException {
FileReader fileReader = new FileReader(filename);
@mchirico
mchirico / SQLite.java
Created February 10, 2013 21:29
Example using the sqlite-jdbc
package dev.sysadmin;
/*
* https://bitbucket.org/xerial/sqlite-jdbc/overview
*
*
*/
import java.sql.Connection;
import java.sql.DriverManager;
@mchirico
mchirico / gist:4966742
Created February 16, 2013 12:34
Java String format
s[0][1]=String.format("a%11.0f", Math.pow(2,32));
@mchirico
mchirico / sorts.py
Created March 1, 2013 23:34
Back of the envelope sorts using dictionary keys or sorts of values
def num(m):
h={}
for i in m:
j=i.split(",")
if (j[0] in h):
h[j[0]]=h[j[0]]+1
else:
h[j[0]]=1
return h