Skip to content

Instantly share code, notes, and snippets.

View eMaringolo's full-sized avatar

Esteban A. Maringolo eMaringolo

View GitHub Profile
@eMaringolo
eMaringolo / main.dart
Last active March 30, 2022 21:55
StreamController not resolving onDone handler when using a StreamTransformer
import 'dart:async';
void main(List<String> arguments) {
var c = StreamController();
var s = c.stream
.transform(StreamTransformer.fromHandlers(handleData: (data, sink) {
sink.add(data);
}, handleDone: (sink) => sink.close()));
s.listen((event) {
@eMaringolo
eMaringolo / gist:bed9974d70c9ab8c6398149716e22b08
Created December 4, 2019 22:44
ZnClient subclass with cache
ZnClient subclass: #ZnCachingClient
instanceVariableNames: ''
classVariableNames: ''
package: 'Zinc-HTTP-CachingClient'
execute
"Execute the currently set up request to generate a response.
If the request was performed before, retrieve the cached version.
Return the #contents of the response, if any."
@eMaringolo
eMaringolo / keybase.md
Last active September 11, 2019 17:30
Keybase Identity Proof

Keybase proof

I hereby claim:

  • I am emaringolo on github.
  • I am emaringolo (https://keybase.io/emaringolo) on keybase.
  • I have a public key whose fingerprint is A693 D5C7 226E 1254 9132 45E6 AE8F 6B83 81F5 D5AD

To claim this, I am signing this object:

@eMaringolo
eMaringolo / bitcoin
Created August 2, 2017 02:34
Ubuntu's /etc/init.d/bitcoin script to run a bitcoin node as daemon/service
#!/bin/sh
### BEGIN INIT INFO
# Provides: bitcoin
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Bitcoin Fullnode
### END INIT INFO
@eMaringolo
eMaringolo / gist:3228968
Created August 1, 2012 17:23
Smalltalk Quine
[ :s | Transcript show: s; show: s printString ] value: '[ :s | Transcript show: s; show: s printString ] value: '
@eMaringolo
eMaringolo / ZnSimpleWebServer.st
Created May 28, 2012 02:18
The simplest hello world server using Zinc HTTP Components <http://zn.stfx.eu/zn/index.html>
(ZnServer startDefaultOn: 1701)
onRequestRespond: [ :request |
ZnResponse ok: (ZnEntity text: 'Hello World!') ]
@eMaringolo
eMaringolo / load-script
Created April 28, 2015 13:45
IntelliJ icons in Pharo
Gofer it
smalltalkhubUser: 'estebanlm' project: 'IconsForPharo';
package: 'Polymorph-Icons-Idea';
load.
ThemeIcons current: IdeaUIThemeIcons new.
AbstractNautilusUI resetIconCaches.
"(you will need to reopen all your windows)"
"The coolness of this icons set is that they work very fine with Dark Theme too :)"
"Compares the parse speed of three different JSON parsers."
{'file1.json'. 'file2.json'. 'file3.json' } do: [ :filename |
jsonString := fileName asFileReference contents.
Transcript cr; show: jsonString size printString, 'bytes JSON:'; cr.
Transcript show: 'NeoJSON: '; show: [ NeoJSONReader fromString: jsonString] bench; cr.
Transcript show: 'JSON: '; show: [Json readFrom: jsonString readStream ] bench; cr.
Transcript show: 'WAJsonParser: '; show: [WAJsonParser parse: jsonString] bench; cr.
]
@eMaringolo
eMaringolo / MandrillClient.st
Created May 30, 2014 03:57
Simple example on how to send emails from Pharo using MandrillApp client
"Get client at http://smalltalkhub.com/#!/~NorbertHartl/Mandrill"
"Set the api key only once."
MandrillClient apiKey: 'yourApiKeyGoesHere'.
(MandrillMessage new
addRecipient: (MandrillRecipient new email: 'alice@there.com');
fromName: 'Bob';
fromEmail: 'bob@yourdomain.com';
subject: 'Sending mails from Pharo';
@eMaringolo
eMaringolo / generator.st
Created May 24, 2014 03:39
8 byte pretty much unique ID generator
"http://instagram-engineering.tumblr.com/post/10853187575/sharding-ids-at-instagram"
| epoch generator ids runLength shardId seqId|
epoch := '01-01-2014' asDateAndTime asUnixTime. "1388545200"
generator := [:seed1 :seed2 |
| id |
id := (DateAndTime now asUnixTime - epoch) bitShift: 64-41.
id := id bitOr: (seed1 bitShift: (64-41-13)).
id := id bitOr: seed2 ].