Skip to content

Instantly share code, notes, and snippets.

View Kwpolska's full-sized avatar

Chris Warrick Kwpolska

View GitHub Profile
@Kwpolska
Kwpolska / TextToSpeech.scpt
Created February 18, 2017 13:54
Text to Speech service
-- USAGE: create an Automator service that receives selected text and put this in "Run AppleScript"
on run {input, parameters}
choose from list {"Alex", "Daniel", "Ewa", "Samantha", "Serena", "Thomas", "Zosia", "Bad News", "Good News", "Pipe Organ"} with prompt "Choose voice:" without multiple selections allowed and empty selection allowed
set voice to the result as string
say input using voice
return input
end run
#!/usr/bin/env python3
from __future__ import print_function
def f(n, level=0):
indent = level * ' '
print(indent, 'start', n)
if n == 10202:
print(indent, 'return constant from', n)
return 4
@Kwpolska
Kwpolska / diff.diff
Last active December 8, 2016 19:02
for loop vs while loop (C, gcc 6.2.1)
--- for.s 2016-12-08 20:00:37.121281039 +0100
+++ while.s 2016-12-08 20:00:38.705280904 +0100
@@ -1,4 +1,4 @@
- .file "for.c"
+ .file "while.c"
.intel_syntax noprefix
.text
.globl main
from functools import wraps
def dec(f):
@wraps(f)
def wrapper(i):
print("wrapper")
return f(i)
return wrapper
@Kwpolska
Kwpolska / Makefile
Created September 24, 2016 11:19
Makefile example for Gynvael’s OSDev
floppy.bin: kernel.c stage1.asm stage2.asm
gcc kernel.c -std=c99 -nostdlib -o kernel64
strip kernel64
nasm stage1.asm
nasm stage2.asm
dd if=/dev/zero bs=1 count=$((512-$(stat --printf="%s" stage1))) >> stage1
cat stage1 stage2 kernel64 > floppy.bin
bash -c 'fsize=$$(stat --printf="%s" floppy.bin); if [[ $$(($$fsize%512)) != 0 ]]; then dd if=/dev/zero bs=1 count=$$((512-($$fsize%512))) >> floppy.bin; fi'
@Kwpolska
Kwpolska / widget-meta2.php
Created September 14, 2016 18:07
WordPress Meta2 widget: a meta widget with less useless cruft.
<?php
/*
Plugin Name: Meta2 Widget
Description: Meta2 Widget.
*/
class WP_Widget_Meta2 extends WP_Widget {
/**
* Sets up a new Meta widget instance.
*
[user]
name = Chris Warrick
email = kwpolska@gmail.com
username = Kwpolska
[color]
ui = 1
diff = auto
status = auto
branch = auto
[github]
#!/usr/bin/env python3
from enum import Enum
from queue import Queue, Empty
class Action(Enum):
addMessage = 1
@Kwpolska
Kwpolska / nikola_changed_output.xml
Created June 23, 2016 11:02
rst2html5 tab issue
N. <raw format="html" xml:space="preserve"><pre class="code bash"><a name="rest_code_d86c70c19454410b923d46ffb81e8c5f-1"></a>sudo vim /etc/lightdm/lightdm-gtk-greeter.conf
</pre></raw>
N. <raw format="html" xml:space="preserve"><pre class="code ini"><a name="rest_code_485b10953d80423e9d1e89fb6aae9041-1"></a><span class="k">[base]</span>
<a name="rest_code_485b10953d80423e9d1e89fb6aae9041-2"></a><span class="na">session</span><span class="o">=</span><span class="s">/usr/bin/startlxde</span>
<a name="rest_code_485b10953d80423e9d1e89fb6aae9041-3"></a><span class="err">...</span>
<a name="rest_code_485b10953d80423e9d1e89fb6aae9041-4"></a><span class="k">[userlist]</span>
<a name="rest_code_485b10953d80423e9d1e89fb6aae9041-5"></a><span class="na">disable</span><span class="o">=</span><span class="s">1</span>
</pre></raw>
N. <raw format="html" xml:space="preserve"><pre class="code python"><a name="rest_code_3c1e76e33f5947f39f83e81945e24503-1"></a><span class="n">foo</span>
<a name="rest_code_3c1e76e33f5947f39f83e81
#!/usr/bin/env python3
from datetime import *
print(datetime.now() + timedelta(100), end=' (local time)\n')