Skip to content

Instantly share code, notes, and snippets.

View philippeback's full-sized avatar
👽
Hackin'

Philippe Back philippeback

👽
Hackin'
View GitHub Profile
class Solution:
def wanted(this, number, target):
return target - number
def twoSum(self, nums: List[int], target: int) -> List[int]:
wanted_dict = {}
for i in range(0, len(nums)):

Eliot Miranda Eliot Miranda, Author of the Cog and BrouHaHa Smalltalk VMs. Ex tech lead for VisualWorks Smalltalk ('99 - '06). Updated Dec 6

I’m not qualified to answer this question; I’m a very experienced and quite strong programmer but I’ve not studied the development and maintenance of large programs, I’ve not managed teams, and I’ve not invented a programming methodology. That said, my experience tells me that the following (none of which are mine) are the rules to live by

KISS, Keep It Simple, Stupid.

When possible, use a simple approach. Adapting Einstein, programs should be as simple as possible, but no simpler. In the absence of perfect optimizers this principle may have to be violated if one is producing a system whose performance is critical and which is run many more times than it is written (such as in an optimizer).

Make it run, make it right, make it fast. In that order.

@philippeback
philippeback / fixpackages.sh
Created January 9, 2019 17:29
Fix Spark Course VM for packages install
#
# To be able to install packages in the VM (since the Linux version used is not supported anymore)
#
# (I wanted vim and mc in there)
#
# Run this as root / sudo
cd /etc/apt
cp sources.list sources.list.backup
sed -i -- 's/\/security/\/old-releases/g' sources.list
s := World instVarNamed: #worldState.
l := s instVarNamed: #stepList.
morphs := l collect: #receiver thenSelect: [ :e | e isKindOf: TransferMorph ].
morphs do: [ :each | s stopStepping: each ].
morphs := nil.
Transcript announcer initialize.
Smalltalk garbageCollect.
SystemWindow allInstances
@philippeback
philippeback / PharoAndStrings.st
Created December 13, 2018 21:53
Pharo and strings fun
words := #('Peek' 'Geek' 'Coke' 'Poke' 'Meaning' 'Zapping' 'Delta' 'force' 'GEEK' 'CoKE' 'ORCa').
forbiddenWords := #('ok' 'eek' 'orc').
words
select: [ :word |
(forbiddenWords
inject: 0
into: [ :sum :forbidden |
sum + (word
findString: forbidden
@philippeback
philippeback / clearwin.st
Created December 11, 2018 21:03
Clear SystemWindows
RubFindReplaceService cleanUp.
EditorFindReplaceDialogWindow cleanUp.
SystemWindow allSubInstances do: [ :each | (each privateOwner: World) ].
SystemWindow allInstances do: [ :w | w openInWorld ].
100 timesRepeat: [ World doOneCycle ].
SystemWindow allInstances do: [ :w | Halt now. w delete ].
100 timesRepeat: [ World doOneCycle ].
SystemWindow allInstances.
Smalltalk garbageCollect
http://ws.stfx.eu/ETS1OXWPQIXK
a) Spec
~~~~~~~~~~~
tm := TextModel new.
tm autoAccept: true. "otherwise you would have to pres ctrl+s to 'save' the result in memory"
tm openWithSpec. "this will open text window
"and then you can do"
tm text. "retrieve current text from the TextModel (returns an instance of Text)"
tm text: 'new content' "set a new content"

Cleaning Audio from Lecture

  • Noise removal
  • Limiter (-8,21.5) (need to install)
  • Normalize
  • Compressor
  • Low pass filter 8000
  • Hi pass filter 100
> I don’t know if there is an existing object reference crawler, but I ported mine from VW. It finds the shortest paths so it is good for finding the reference that is causing the memory leak.
>
> MCHttpRepository
> location: 'http://www.smalltalkhub.com/mc/JohnBrant/ReferenceFinder/main'
> user: ''
> password: ‘’
>
> Once loaded, you can evaluate something like "ReferenceFinder findPathToInstanceOf: MyClass”. That will return a reference path or nil if no path exists from the Smalltalk global to an instance of MyClass. If you want to find a path to a particular instance, you can use “ReferenceFinder findPathTo: myInst”.
>
> In the past, I’ve found that NECController and some compiler infrastructure (I forget the class) have been culprits for memory leaks with their caches.