Skip to content

Instantly share code, notes, and snippets.

@rashivkp
rashivkp / linkedin-icon-for-jekyll-footer.html
Last active June 21, 2022 06:00
linkedin svg icon for jekyll page footer
@rashivkp
rashivkp / tunnel_dot.sh
Last active March 15, 2021 12:15
running local tunnel with nginx
# 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
@rashivkp
rashivkp / convert_to_ogg.py
Last active July 29, 2020 06:35
Convert aac, amr files in a folder to ogg format with same name. And remove original file.
#! /usr/bin/python
import sys
from subprocess import call
import os.path
dest_ext = "ogg"
def convert(source):
print("Source: " + source)
extension = source[-3:]
@rashivkp
rashivkp / app.py
Created February 21, 2019 12:39
return helloworld for every route
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]
@rashivkp
rashivkp / ajax.php
Created September 11, 2016 19:49
php ajax sample json response
<?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));
@rashivkp
rashivkp / split.rb
Created March 14, 2017 14:33 — forked from venj/split.rb
Split a image into two halves.
#!/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|
@rashivkp
rashivkp / sanchai-userscript.js
Created January 19, 2016 05:49
sanchai mapping - userscript to ease the data entry
// ==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==

book : The Elements of Computing Systems

<?php
class User_model extends CI_Model {
function __construct()
{
parent::__construct();
}
/**
* authenticate user login
#1 schools
select
RM.rev_district_name,
count(CASE WHEN SD.class_end IN (4, 5) and S.school_type='G' THEN SD.school_code END ) AS GovPrimarySchools,
count(CASE WHEN SD.class_end IN (4, 5) and S.school_type='A' THEN SD.school_code END ) AS AidPrimarySchools,
count(CASE WHEN SD.class_end IN (4, 5) and S.school_type='U' THEN SD.school_code END ) AS AidPrimarySchools,
count(CASE WHEN SD.class_end =7 and S.school_type='G' THEN SD.school_code END ) AS GovUpperPrimarySchools,
count(CASE WHEN SD.class_end =7 and S.school_type='A' THEN SD.school_code END ) AS AidUpperPrimarySchools,
count(CASE WHEN SD.class_end =7 and S.school_type='U' THEN SD.school_code END ) AS AidUpperPrimarySchools,
count(CASE WHEN SD.class_end IN (8, 9, 10) and S.school_type='G' THEN SD.school_code END ) AS GovSecondarySchools,