Skip to content

Instantly share code, notes, and snippets.

View jamesladd's full-sized avatar
💭
Coding like the wind

James Ladd jamesladd

💭
Coding like the wind
View GitHub Profile
@jamesladd
jamesladd / Object.st
Last active January 31, 2017 21:14
Object.st snippet
PrimObject subclass: #Object.
"category: accessing"
- class
"Primitive. Answer the object which is the receiver's class."
JVM primitive: 111.
- yourself
^ self.
@jamesladd
jamesladd / HelloWorld.st
Created January 31, 2017 21:04
Hello World in Redline Smalltalk
Transcript cr; show: 'Hello World from Redline Smalltalk.'; cr.
@jamesladd
jamesladd / EastCollection.java
Last active January 30, 2017 03:56
An East Collection
package com.east;
import java.util.*;
interface ContainedListener {
void notifyContained(Object item, boolean matched);
}
public class PermissionService implements ContainedListener {
@jamesladd
jamesladd / ansi_v1.rb
Last active August 29, 2015 14:15
Original ansi.rb requiring more than 12 test to prove to_ansi method works as expected vs new version requiring 3 tests to prove to_ansi method works as expected.
# - ORIGINAL - Requires 12 test cases the provide to_ansi does what it should
# 1. Test empty commands map returns ""
# 2. 11 Tests to test each if/elsif.
#
class Clear; end
class HideCursor; end
class ShowCursor; end
class SetPos < Value.new(:row, :column); end
class FG < Value.new(:red, :green, :blue); end
@jamesladd
jamesladd / generated-smalltalk-adaptor
Created November 9, 2012 21:45
Smalltalk generated to adapt to Java's ArrayList
******
IN DynamicJavaClassAdaptor.build
"@: smallTalkClassesThatAdaptJavaClasses.java.util.ArrayListAdaptor"
import: 'java.util.List' as: 'smallTalkClassesThatAdaptJavaClasses_java_util_ListAdaptor'.
import: 'java.util.ListIterator' as: 'smallTalkClassesThatAdaptJavaClasses_java_util_ListIteratorAdaptor'.
import: 'java.util.Iterator' as: 'smallTalkClassesThatAdaptJavaClasses_java_util_IteratorAdaptor'.
import: 'java.lang.Object' as: 'smallTalkClassesThatAdaptJavaClasses_java_lang_ObjectAdaptor'.
Object < #ArrayListAdaptor.
ArrayListAdaptor class atSelector: #withCollection: put: [ :args || obj |
JVM new:'java/util/ArrayList'.
@jamesladd
jamesladd / koal-facebook-post
Created September 29, 2011 02:47
Post picture to wall on facebook
to create Facebook events with a picture through the Graph API you need to use a multipart post request and give the image the key "picture".
This is not documented. At all. Anywhere. Except here.
To do this in Koala, you can use a line like this:
graph = Koala::Facebook::GraphAPI.new( oauth.get_app_access_token )
graph.put_object( APP_ID, "events", {
:name => "Some event",
:start_time => Time.now.to_s,
:description => "Facebook API docs suck",
@jamesladd
jamesladd / facebook_gist.rb
Created September 16, 2011 02:00
Using Facebook API server side
require 'rubygems'
require 'koala'
#
# initialize a Graph API connection
@oauth = Koala::Facebook::OAuth.new(app_id, app_secret, "https://www.facebook.com/connect/login_success.html")
@url_for_oauth_code = @oauth.url_for_oauth_code(:permissions => "publish_stream")
puts @url_for_oauth_code.inspect
@your_oauth_token = "goto above printed url and copy code= upto # into this string, then run again."
@jamesladd
jamesladd / facebook_post.rb
Created September 7, 2011 00:29
Writing to facebook users wall server side ....
require 'rubygems'
require 'koala'
#
# initialize a Graph API connection
@oauth = Koala::Facebook::OAuth.new(app_id, code, "https://www.facebook.com/connect/login_success.html")
@url_for_oauth_code = @oauth.url_for_oauth_code(:permissions => "publish_stream")
puts @url_for_oauth_code.inspect
# Goto the URL printed above in your browser - it should print 'success' and in the
@jamesladd
jamesladd / gist:814154
Created February 7, 2011 08:50
delete all gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@jamesladd
jamesladd / gist:797477
Created January 26, 2011 21:15
ANTLR grammar for smalltalk chunks
program returns [Program n]
: (chunk)* EOF
;
chunk returns [Chunk n]
: sequence EOF
| sequence '!'
| '!' sequence '!'
| messagePattern sequence '! !'
;