Skip to content

Instantly share code, notes, and snippets.

View bishwanathjha's full-sized avatar
🏠
Working from home

Bishwanath Jha bishwanathjha

🏠
Working from home
View GitHub Profile
@bishwanathjha
bishwanathjha / API-Language
Created June 23, 2014 12:50
API-Language
LANGUAGE API GET Response
GET /core/v1/Language
{
"data": [
{
"id": 1,
"locale": "en-us",
"icon": "\/__swift\/apps\/base\/assets\/__universal\/flags-iso\/64\/US.png",
"is_master": true,
<?php
function StairCase($n) {
for($i = 1; $i <= $n; $i++) {
for($j = $n; $j >= 1; $j--) {
echo ($j <= $i) ? "#" : " ";
}
echo "\n";
}
@bishwanathjha
bishwanathjha / contiguous_subarray_sum.php
Created October 23, 2016 15:28
Largest Sum Contiguous Subarray in PHP
<?php
/**
* @author Bishwanath Jha <bishwanathkj@gmail.com>
* Largest Sum Contiguous Subarray
*/
function GetMaxSum($array) {
$total = $max_total = 0;
$count = count($array);
for($i = 0; $i < $count; $i++) {
$total += $array[$i];
@bishwanathjha
bishwanathjha / prime_number_list.php
Last active October 27, 2016 08:41
List all the prime numbers less than or equal to a given integer n in PHP
<?php
/**
* @author Bishwanath Jha <bishwanathkj@gmail.com>
* Give the nth number as input and it will return all prime numbers less than or equal to that number
*/
function GetPrimeNumberList($num) {
if ($num == 1) {
return $num;
}
@bishwanathjha
bishwanathjha / tmux.conf
Created November 15, 2017 17:30 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@bishwanathjha
bishwanathjha / mysql_database_backup_bash_script.sh
Created December 3, 2019 10:16
Bash script to backup mysql database, upload backup to aws s3 and notify on slack
#!/bin/bash
# Database credentials
user="db_user"
password="db_password"
host="127.0.0.1"
db="database"
prefix="db"
# Other options
backup_path="/home/ec2-user"
@bishwanathjha
bishwanathjha / sqldump_remove_insert_tables
Last active October 11, 2021 06:05
Remove large insert statements from mysql dump file
# I am going to remove the activies insert from sql file because that huge aroudn 500MB
# Below command will create a new sql file by removing the activities insert query
sed '/INSERT INTO `activities`/d;/INSERT INTO `reconciliation_statement`/d;/INSERT INTO `activity_actions`/d' mydb.sql > reduced.sql
@bishwanathjha
bishwanathjha / moodle_query_get_attendance_studentwise_coursewise.sql
Last active May 1, 2020 21:30
Moodle Query to get Attendance Student wise Course Wise
-- Moodle get student wise attendence for each courses
-- To filter data you can put the parent course id and start {start_date_epoch} and end {end_date_epoch} in where clause
select
l.id as logid,
c.fullname as course,
CONCAT(FROM_UNIXTIME(s.sessdate,"%d %b, %Y %h:%i %p"), ' - ', FROM_UNIXTIME(s.sessdate + s.duration ,"%h:%i %p")) as session_title,
-- s.description as session_desc,
u.id as student_id,
u.username,
u.firstname as first_name,
@bishwanathjha
bishwanathjha / create_requests_zendesk_api.php
Created June 10, 2020 07:39
Create request/ticket on zendesk using API sample request
<?php
# To enable anonymous requests on zendesk so that you can create new request using API:
# - Sign in to Support and go to the Customers page (Admin > Settings > Customers).
# - Enable "Anyone can submit tickets".
# - Disable "Ask users to register".
$data = '{
"request": {
"requester": {
@bishwanathjha
bishwanathjha / compress-pdf-with-gs.md
Created March 10, 2021 04:08 — forked from guifromrio/compress-pdf-with-gs.md
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.