Skip to content

Instantly share code, notes, and snippets.

View nmccready's full-sized avatar

nmccready nmccready

View GitHub Profile
<!-- File: app/views/layouts/application.html.erb -->
<%= yield %>
@nmccready
nmccready / checkSwap.sh
Last active December 26, 2015 09:29
OSX swap check 4 eva
#!/bin/sh
run=1
while [ $run ]
do
echo 'Swap Space monitoring forever.'
echo '------------------------------'
echo ' '
echo ' '
ls -lh /private/var/vm/swapfile*
sleep 2
@nmccready
nmccready / addUserToGroup
Created October 25, 2013 15:48
adding a user to a group in osx
#!/bin/sh
user=${1?need user name!}
group=${2?need group name!}
/usr/sbin/dseditgroup -o edit -a "$user" -t user "$group"
@nmccready
nmccready / concatComa.rb
Last active December 26, 2015 22:39
Script to take in a row of mysql ids and put put them with quotes and commas. So do a copy row unquotes from MySQL workbench and paste it with this script.
# usage as shown below
# $>ruby concatComa "1 2 3 4 5555555"
# $>"1","2","3","4","5555555"
v1 = ARGV[0]
puts v1.to_s.split.to_s[1..-2]
@nmccready
nmccready / listGroups
Created November 4, 2013 13:25
OSX script to list user groups
#!/bin/sh
dscl . list /groups
set fo=tcq
set nocompatible
set modeline
syntax on
highlight comment ctermfg=cyan
set tabstop=2
set expandtab

Asynchronicity is the price to pay, you better know what you're paying for...

Let's share some vocabulary first:

Thread: The primitive responsible of executing code on the processor, you can give an existing (or a new) Thread some code, and it will execute it. Normally you can have a few hundreds on a JVM, arguments that you can tweak your way out to thousands. Worth noting that multitasking is achieved when using multiple Threads. Multiple Threads can exist for a single processor in which case multitasking happens when this processor switches between threads, called context switching, which will give the impression of things happenning in parallel. An example of a direct, and probably naive, use of a new Thread in Java:

public class MyRunnable implements Runnable {
  public void run(){
 System.out.println("MyRunnable running");