Skip to content

Instantly share code, notes, and snippets.

View gsingh93's full-sized avatar

Gulshan Singh gsingh93

View GitHub Profile
@gsingh93
gsingh93 / gdb_init_real_mode.txt
Created June 17, 2018 01:32
Mirror of this GDB script for debugging x86 16-bit real mode code: http://www.capp-sysware.com/misc/stackoverflow/gdb_init_real_mode.txt
# Special mode for GDB that allows to debug/disassemble REAL MODE x86 code
#
# It has been designed to be used with QEMU or BOCHS gdb-stub
#
# 08/2011 Hugo Mercier - GPL v3 license
#
# Freely inspired from "A user-friendly gdb configuration file" widely available
# on the Internet
set confirm off
@gsingh93
gsingh93 / setup-qemu-arm.sh
Created May 23, 2016 09:44
Installs and configures QEMU to run ARM binaries on Ubuntu 14.04
#!/bin/bash
URL=http://wiki.qemu-project.org/download/
latest_qemu=$(curl --silent $URL | grep -oP "\bqemu-[0-9.]+\.tar\.bz2\b" | sort | uniq | tail -n 1)
basename=$(basename $latest_qemu .tar.bz2)
if [[ ! -d $basename ]]; then
echo "[+] Downloading latest QEMU: $latest_qemu"
wget $URL/$latest_qemu
@gsingh93
gsingh93 / loghw.sh
Created December 13, 2014 23:16
A script to log cpu usage, memory usage, and temperature usage
#!/bin/bash
# A script to log cpu usage, memory usage, and temperature usage
# TODO:
#
# Log temp awk is not portable
# Validate interval
#
@gsingh93
gsingh93 / markMutedAsRead.gs
Created September 4, 2021 04:27
Marked muted emails as read with Google AppsScript
// Create a new AppScript project (https://script.google.com/home/start)
// and schedule this to be run every hour
function markMutedAsRead() {
var threads = GmailApp.search('is:muted is:unread');
for (var i = 0; i < threads.length; i++) {
threads[i].markRead();
}
}
@gsingh93
gsingh93 / segment_tree.rs
Last active October 27, 2016 13:38
Segment tree implementation in Rust
use std::fmt::Show;
use std::default::Default;
use std::ops::Add;
struct SegmentTree<T> {
size: uint,
root: Node<T>
}
struct Node<T> {
@gsingh93
gsingh93 / print_heap_sizes.c
Created September 23, 2016 06:59
Print the requested, usable, and real sizes of a heap chunk
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
int main() {
printf("size of size_t: %zu\n", sizeof(size_t));
int i;
for (i = 0; i < 10; i++) {
size_t size = i * 8;
void *m = malloc(size);
@gsingh93
gsingh93 / comptime
Created August 29, 2013 23:28
Compare the running times of two programs
#!/bin/bash
prog1=$1
prog2=$2
num_times=${3:-10}
calculate_mean() {
sum=0
for n in $@; do
sum=$(($sum+$n))
@gsingh93
gsingh93 / wpvuln.py
Created December 8, 2015 15:58
Check for WordPress plugin vulnerabilities
#!/usr/bin/env python2
import requests
import json
from pprint import pprint
wp_version = '4.3'
plugins = []
print '[+] Checking WordPress version ' + wp_version
git push -q -f heroku HEAD:master
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Fetching custom git buildpack... done
remote: -----> Haskell app detected
remote:
remote:
remote: -----> Welcome to Haskell on Heroku
remote: BUILDPACK_URL: https://github.com/mietek/haskell-on-heroku
use std::io;
use std::str::FromStr;
use std::num::Float;
// http://codeforces.com/contest/1/problem/A
fn main() {
let l = io::stdin().read_line().unwrap();
// We need the .trim() because of the newline. Annoying
// Can't do it on one line because of lifetime error. Also annoying.
let l = l.trim();