Skip to content

Instantly share code, notes, and snippets.

View diewland's full-sized avatar
🧩
Jigsaw Fam

diewland.eth diewland

🧩
Jigsaw Fam
View GitHub Profile
@diewland
diewland / inside_audio_segment_from_file.py
Last active August 7, 2019 12:34
subprocess in pydub.AudioSegment.from_file
# https://github.com/jiaaro/pydub/blob/master/pydub/audio_segment.py
if filename:
conversion_command += ["-i", filename]
stdin_parameter = None # <------------------------------------------- Look at this line !!
stdin_data = None
else:
if cls.converter == 'ffmpeg':
conversion_command += ["-read_ahead_limit", str(read_ahead_limit),
"-i", "cache:pipe:0"]
@diewland
diewland / inside_audio_segment_from_file_using_temporary_files.py
Created August 7, 2019 12:14
subprocess in pydub.AudioSegment.from_file_using_temporary_files
# https://github.com/jiaaro/pydub/blob/master/pydub/audio_segment.py
with open(os.devnull, 'rb') as devnull:
p = subprocess.Popen(conversion_command, stdin=devnull, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p_out, p_err = p.communicate()
# On Windows, running this from the binary produced by Pyinstaller
# with the ``--noconsole`` option requires redirecting everything
# (stdin, stdout, stderr) to avoid an OSError exception
# "[Error 6] the handle is invalid."
ret.update({'stdin': subprocess.PIPE,
'stderr': subprocess.PIPE,
'startupinfo': si,
'env': env })
return ret
import re
def validate_thai_filename(filename):
return re.sub('[^ก-๙a-zA-Z0-9.,_-]', '_', filename)
@diewland
diewland / onblur-next-target.js
Last active June 25, 2019 11:23
Find onblur next target
/* https://stackoverflow.com/a/11544685/466693 */
// focus on first element
$('.my-text').eq(0).focus();
// onblur event
$('.my-text').blur(function (event) {
// do onblur stuff
// ...
@diewland
diewland / profiles.json
Last active June 14, 2019 09:31
The new terminal profiles
{
"globals" :
{
"alwaysShowTabs" : true,
"defaultProfile" : "{09dc5eef-6840-4050-ae69-21e55e6a2e62}",
"initialCols" : 120,
"initialRows" : 30,
"keybindings" :
[
{
@diewland
diewland / .gitconfig
Last active May 29, 2019 10:59
Change editor in git
...
br = branch
co = checkout
[core]
autocrlf = input
editor = gvim <---- change editor command
[color]
diff = auto
status = auto
branch = auto
@diewland
diewland / preview_random_5_items.py
Last active May 4, 2019 03:51
Preview random 5 items from list
import random
rows = [ 1, 2, 3, ... ] # your list
print([ random.choice(rows) for i in range(5) ])
@diewland
diewland / basic-gmail-accounts.csv
Created April 19, 2019 22:18
Basically Gmail Accounts
Gmail Account Google Drive Space
Main Small
Secondary Very Large
@diewland
diewland / MainActivity.java
Created August 30, 2018 02:56
Eddystone URL Demo
/*
https://github.com/adriancretu/beacons-android
*/
package com.diewland.fake_beacons;
import android.app.Activity;
import android.os.Bundle;
import com.uriio.beacons.Beacons;
import com.uriio.beacons.model.EddystoneURL;
public class MainActivity extends Activity {