Skip to content

Instantly share code, notes, and snippets.

View SergeStinckwich's full-sized avatar
🎯
Focusing

Serge Stinckwich SergeStinckwich

🎯
Focusing
View GitHub Profile
@SergeStinckwich
SergeStinckwich / gist:6fe960a6b74ba6257e76
Last active August 29, 2015 14:04
Init script for Pharo images using PharoLauncher (adapted from the one of Torsten Bergmann)
| sharedPackageCacheDirectory |
"Never apply to PharoLauncher itself"
(SmalltalkImage current imageName includesSubstring: 'Launcher') ifTrue: [ ^self ].
"ask if script should be applied"
(UIManager default confirm: 'Apply init script from ', StartupPreferencesLoader preferencesGeneralFolder fullName,' to image') ifFalse: [^self ].
"Use a shared package cache to store Monticello MCS files for all images"
sharedPackageCacheDirectory := (StartupPreferencesLoader preferencesGeneralFolder fullName, 'commonpackage-cache') asFileReference
ensureCreateDirectory;
@SergeStinckwich
SergeStinckwich / gist:b84e1f4ae485cda7d6c9
Created August 5, 2014 16:31
Retrieve my avatar picture as a 70*70 jpeg file
(ZnEasy getJpeg: 'http://www.gravatar.com/avatar/',
(ZnDigestAuthenticator md5Hash: 'serge.stinckwich@gmail.com'),'?s=70'
) asMorph openInWorld
@SergeStinckwich
SergeStinckwich / gist:58f917741ee4e77992ec
Last active August 29, 2015 14:04
Visualization of last 30 days of earthquakes
| b tab |
tab := RTTabTable new input: (ZnEasy get: 'http://earthquake.usgs.gov/earthquakes/feed/v0.1/summary/2.5_month.csv') entity string usingDelimiter: $,.
tab removeFirstRow.
tab replaceEmptyValuesWith: '0' inColumns: #(2 3 4 5).
tab convertColumnsAsFloat: #(2 3 4 5).
b := RTMapLocationBuilder new.
b shape circle
size: [ :v| (2 raisedTo: v) / 2 ];
color: (Color red alpha: 0.3).
tab values do: [ :row | b addPoint: row second @ row third value: row fifth ].
@SergeStinckwich
SergeStinckwich / gist:db394eb02a7fc56cd650
Last active August 29, 2015 14:04
Aviation accidents in 2014
|array b|
array := (NeoCSVReader on: (ZnEasy get: 'http://kathy.cartodb.com/api/v2/sql?format=csv&q=SELECT+*+FROM+aviation_accidents_in_2014') entity string readStream)
skipHeader;
upToEnd.
b := RTMapLocationBuilder new.
b shape circle
size: [ :v| v];
color: (Color red alpha: 0.3).
array do: [ :row | |fatalities|
@SergeStinckwich
SergeStinckwich / gist:24c5ba61d8cd5915cc17
Created March 13, 2015 08:48
Senegal pop with M/F ratio
|tab ds b lb |
tab := RTTabTable new input: 'http://senegalouvert.org/data/core/Population-Senegal/r/Population%20Senegal.csv' asUrl retrieveContents usingDelimiter: $,.
tab removeFirstRow.
tab convertColumnsAsFloat: #(1 2 3 4).
b := RTGrapher new.
ds := RTDataSet new.
ds interaction popup.
ds points: tab values.
ds dotShape color: (Color blue alpha: 0.3).
Gofer new
url: 'http://www.smalltalkhub.com/mc/SergeStinckwich/SciSmalltalk/main';
package: 'ConfigurationOfSciSmalltalk';
load.
(Smalltalk at: #ConfigurationOfSciSmalltalk) loadDevelopment.
pi := (1 asArbitraryPrecisionFloatNumBits: 129) pi.
str := (String new: 32) writeStream.
pi absPrintExactlyOn: str base: 10.
str contents
"http://www.informatik.uni-bremen.de/agbkb/lehre/extratreffen/Santiago102007Interval.pdf"
f := [ :x : y|
((333.75 - (x raisedTo:2))* (y raisedTo: 6)) + ((x raisedTo: 2) *
((11* (x raisedTo: 2) * (y raisedTo: 2)) - (121 * (y raisedTo: 4)) - 2))
+ (5.5 * (y raisedTo: 8)) + (x/(2*y))
].
f value: 77617 value: 33096. "1.1726039400531787"
@SergeStinckwich
SergeStinckwich / gist:1008000
Created June 4, 2011 15:51
One liners in Smalltalk
"Smalltalk version of http://solog.co/47/10-scala-one-liners-to-impress-your-friends/ "
"1. Multiple Each Item in a List by 2"
(1 to: 10) * 2.
"2. Sum a List of Numbers"
"Version 1"
(1 to:1000) reduce:[:a :b|a+b].
"Version 2"
(1 to:1000) sum.
##############################################################
japanino.name=Gakken Japanino(学研 大人の科学 ジャパニーノ)
japanino.upload.protocol=stk500
japanino.upload.maximum_size=14336
japanino.upload.speed=19200
japanino.bootloader.low_fuses=0xe2
japanino.bootloader.high_fuses=0xdd
@SergeStinckwich
SergeStinckwich / gist:4707579
Created February 4, 2013 15:51
public static boolean isAnAnagram(String c1, String c2)
class Exo3 {
public static boolean isAnAnagram(String c1, String c2){
int [] counts = new int[26];
int l1 = c1.length();
int l2 = c2.length();
if (c1.equals(c2)) return true;
if (l1 != l2) return false;