Skip to content

Instantly share code, notes, and snippets.

View cuckookernel's full-sized avatar
🎯
Focusing

Mateo Restrepo Mejía cuckookernel

🎯
Focusing
View GitHub Profile
#!/bin/env python
"""
Turn a long text into a sound file, using Coqui TTS: text-to-speech
Example usage:
./doc_2_audio.py -e utf16 my_dir/my_document.txt
Will produce output my_dir/my_document.wav
@cuckookernel
cuckookernel / restart-nvidia-gpu.sh
Created June 18, 2023 16:59
Restart nvidia GPU after hybernation
# Optional To find out what processes are using GPU
sudo fuser -v /dev/nvidia*
# to restart
sudo rmmod nvidia_uvm && sudo modprobe nvidia_uvm
# remove unsused packages
sudo apt-get autoremove
# clean APT cache
sudo apt-get clean
# clean oldish journal logs
sudo journalctl --vacuum-time=1d
# remove old versions of snap packages
extension Array where Element == Double {
func mean() -> Double {
if self.count == 0 { return Double.nan }
var ret = 0.0
for x in ret {
ret += x
struct InfRepeater: Sequence {
// a sequence that loops infinitely over another sequence
typealias Iterator = InfRepeaterIter
typealias Element = Int
var arr: Array<Element>
func makeIterator() -> Iterator {
return InfRepeaterIter( i: 0, arr: arr )
}
}
@cuckookernel
cuckookernel / extension_sequence.swift
Created August 3, 2019 17:27
Extending Swift's sequence
extension Sequence {
func take(_ n: Int ) -> [Self.Element] {
// yield the first n elements of a sequence as an array
var ret = [Self.Element]()
for ( _, e) in zip( 0..<n, self ) {
ret.append(e)
}
return ret
}
Inferred types from first 100 line(s) of file as
column_type_hints=[int,str,float,float,int]
------------------------------------------------------
Read 870755 lines. Lines per second: 520097
Finished parsing file /home/ubuntu/dask_experiment/Gowalla_totalCheckins.txt
Parsing completed. Parsed 6442892 lines in 5.43026 secs.
+---------+-----------+----------------+
| stalkee | stalker | location_count |
+---------+-----------+----------------+
final_result = ( pairs_filtered[['stalkee', 'stalker', 'location_id']]
.unique()
.groupby( ['stalkee','stalker'] ,
{"location_count" : agg.COUNT })
.topk( 'location_count', k=5 )
.materialize() )
print( final_result )
chin_ps = ( checkins.join( checkins, on = 'location_id' )
.rename( {'checkin_ts' : 'checkin_ts_ee',
'checkin_ts.1' : 'checkin_ts_er',
'user_id' : 'stalkee' ,
'user_id.1' : 'stalker' } ) )
pairs_filtered = chin_ps[ (chin_ps['checkin_ts_ee'] < chin_ps['checkin_ts_er']) &
(chin_ps['stalkee'] != chin_ps['stalker]) ]
import turicreate as tc
checkins = ( tc.SFrame.read_csv( 'Gowalla_totalCheckins.txt',
delimiter='\t', header=False )
.rename( {'X1': 'user_id', 'X2' : 'checkin_ts',
'X3': 'lat', 'X4' : 'lon',
'X5': 'location_id'} )
[["user_id", "location_id", "checkin_ts"]] )