View prefix_function.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION public.prefixes(character varying) RETURNS character varying[] | |
LANGUAGE sql IMMUTABLE | |
AS $_$ | |
SELECT ARRAY(SELECT substring($1 FROM 1 FOR i) | |
FROM generate_series(1, GREATEST(length($1))) g(i))::varchar[]; | |
$_$ | |
SELECT MAX(prefix) FROM MY_TABLE WHERE prefix=ANY(content); |
View notify_watch.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fd = inotify_init(); | |
$watch_descriptor = inotify_add_watch($fd, './watch', IN_CLOSE_WRITE); | |
while (true) { | |
$events = inotify_read($fd); | |
foreach ($events as $event) { |
View read_stdin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
while (!feof(STDIN)) { | |
$f = fgets(STDIN); | |
if ($f) { | |
echo ">> $f\n"; | |
} | |
} |
View thread_pool.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thread' | |
queue = Queue.new | |
threads = [] | |
1.step(1000) do |i| | |
queue << i | |
end | |
8.times do |
View main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
t, _ := time.Parse("2006-01-02 15:04", "2021-05-17 10:55") | |
today := t.Weekday() |
View main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net" | |
"os" | |
"strings" | |
) | |
// GetMachineInfo return a list of: |
View html_dom_example.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$doc = new DOMDocument(); | |
$doc->loadHTMLFile('test.html', LIBXML_NOWARNING | LIBXML_NOERROR); | |
$nodes = $doc->getElementsByTagName('head'); | |
if ($nodes->length <= 0) { | |
die('no head found'); | |
} |
View israeli_id.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
def validate_id_number(id_num): | |
anID = id_num.zfill(9) | |
return sum( | |
sum( | |
map( | |
int, str(int(a)*(i % 2 + 1)) | |
) |
View concat-wav.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io" | |
"io/ioutil" | |
"github.com/moutend/go-wav" | |
) | |
func main() { |
NewerOlder