book : The Elements of Computing Systems
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
# find mkcert ca path | |
# mkcert -CAROOT | |
# running local tunnel with local https server (nginx), using self signed certificates (mkcert), | |
lt --local-host api.dot.test --port 443 --subdomain dotapi --local-key /home/rashi/src/local-ssl-keys/_wildcard.dot.test+4-key.pem --local-ca /home/rashi/.local/share/mkcert/rootCA.pem --local-cert /home/rashi/src/local-ssl-keys/_wildcard.dot.test+4.pem --local-https true |
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
from flask import Flask | |
from werkzeug.routing import BaseConverter | |
app = Flask(__name__) | |
class RegexConverter(BaseConverter): | |
def __init__(self, url_map, *items): | |
super(RegexConverter, self).__init__(url_map) | |
self.regex = items[0] |
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/python | |
import sys | |
from subprocess import call | |
import os.path | |
dest_ext = "ogg" | |
def convert(source): | |
print("Source: " + source) | |
extension = source[-3:] |
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 ruby | |
require "fileutils" | |
(puts "Usage: #{File.basename $0} widthxheight"; exit 0) if ARGV.size != 1 | |
width, height = ARGV[0].split("x").collect(&:to_i) | |
(puts "Please enter a valid size."; exit 0) if ((width.to_i == 0) or (height.to_i == 0)) | |
half_width = width / 2 | |
FileUtils.cd("images") do | |
Dir['**/*'].each do |f| |
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 | |
if (isset($_POST['name'])) { | |
header('Content-type: application/json'); | |
if ($_POST['name'] != 'hi') { | |
$array = ['result' => 'fail', 'data' => '100']; | |
} else { | |
$array = ['result' => 'success', 'data' => '100']; | |
} | |
die(json_encode($array)); |
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
// ==UserScript== | |
// @name so | |
// @namespace ALL | |
// @version 1 | |
// @grant none | |
// @include http://sanchaya.lsgkerala.gov.in/assessment/* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js | |
// @require https://greasyfork.org/scripts/1003-wait-for-key-elements/code/Wait%20for%20key%20elements.js?version=49342 | |
// ==/UserScript== | |
// ==UserScript== |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
select distinct student, date, sum(if(ifnull(k1.hour, 0)>0, 1, 0)) as fornoon, | |
sum(if(ifnull(k2.hour, 0)>0, 1, 0)) as afternoon from t1 | |
left join t1 k1 on k1.student=t1.student, k1.date=t1.date and hour between 1, 4 | |
left join t1 k2 on k2.student=t1.student, k2.date=t1.date and hour between 5, 7 | |
; another approach, not tested | |
SELECT student, date | |
count(CASE WHEN t1.hour between 1,4 THEN 1 END ) AS fornoon, |
NewerOlder