Skip to content

Instantly share code, notes, and snippets.

# Sync Data From sasthrolsavamDB to KalolsavamDB
# ==============================================
# Insert school details from another db
INSERT INTO `kalolsavam_2013`.`school_details`
(`school_code`, `class_start`, `class_end`, `school_phone`, `school_email`,
`hm_name`, `hm_phone`, `principal_name`, `principal_phone`,
`teachers`, `strength_lp`, `strength_up`, `strength_hs`,
`strength_hss`, `strength_vhss`, `total_strength`,
@rashivkp
rashivkp / sasthrolsavam.sql
Created November 28, 2013 16:24
list of participants by appeal, who got ranks 1, 2, 3
SELECT pid.participant_name, sm.school_name, pid.item_code, im.item_name, rm.rank
FROM result_master AS rm
JOIN participant_item_details AS pid ON pid.participant_id = rm.participant_id
JOIN school_master AS sm ON sm.school_code = pid.school_code
JOIN item_master as im on im.item_code = rm.item_code
WHERE rm.`spo_id` > 0
AND rm.`rank` in (1, 2, 3)
order by rm.rank;
#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,
<?php
class User_model extends CI_Model {
function __construct()
{
parent::__construct();
}
/**
* authenticate user login
@rashivkp
rashivkp / rename-files.sh
Last active August 29, 2015 14:07
rename files based on parent directory
#!/bin/bash
# change docRoot
docRoot=~/src/shakir/
for semester in */;
do
semester="${semester%?}"
cd "$docRoot/$semester/"
for branch in */;
@rashivkp
rashivkp / dump.sh
Last active August 29, 2015 14:09 — forked from cal/dump.sh
#!/bin/bash
credentials=''
database=''
TABLES=`mysql $credentials -B -N -e "select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA='$database'"`
for table in $TABLES; do
echo -n "dumping $database.$table... "
if [[ $table == cache* ]]; then
### Keybase proof
I hereby claim:
* I am rashivkp on github.
* I am rashivkp (https://keybase.io/rashivkp) on keybase.
* I have a public key whose fingerprint is D11F 7E91 320B 8862 F266 4987 85A3 0001 E0EC 2C29
To claim this, I am signing this object:
@rashivkp
rashivkp / make-it-mysql-compatible.keys
Last active August 29, 2015 14:27
Make a oracle sql compatible with mysql by removing unwanted lines
:g/\v^Insert into DISE2K_|^Insert into STEPS_R|^Insert into CHK_TABLE|^Insert into RTE_COMPLAINT|^Insert into SCH_TEMP|^Insert into SCH_TEMP1|^Insert into STEPS_AUTH|^Insert into STEPS_CWSNCHILDDB|^Insert into STEPS_DATE|^Insert into STEPS_DBINFO|^Insert into STEPS_DCF2PRINT|^Insert into STEPS_DISTPHASE|^Insert into STEPS_PIVOT|^Insert into STEPS_POP4COMPRATE|^Insert into STEPS_POPULATION_ALL|^Insert into STEPS_PRINTDCF|^Insert into STEPS_QUERY|^Insert into STEPS_RMSASUBJECTS|^Insert into STEPS_R_ANAREPBYMCR|^Insert into STEPS_R_ANAREPINFO|^Insert into STEPS_R_ENRBYMCR_SCR|^Insert into STEPS_R_EREPBYMCR|^Insert into STEPS_R_REPINFO|^Insert into STEPS_R_SCHGRADE|^Insert into STEPS_R_SREPBYMCR|^Insert into STEPS_R_TREPBYMCR|^Insert into STEPS_SCHBYCATMGT|^Insert into STEPS_SCHGRADING|^Insert into STEPS_TEACHER_RTE|^Insert into STEPS_TEHSIL|^Insert into STEPS_TOTDISABILITY|^Insert into STEPS_TOTENROLMENT|^Insert into STEPS_TOTPINCENTIVES|^Insert into STEPS_TOTUINCENTIVES/d
:g/^--/d
:g/^ ALTER TABLE/d
:g/^ UNI
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,
@rashivkp
rashivkp / presentation-jupyter.ipynb
Created December 17, 2015 18:17
presentation notebook on jupyter. Install https://github.com/damianavila/RISE to show it as presentation within the notebook itself.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.