Skip to content

Instantly share code, notes, and snippets.

View hiway's full-sized avatar

Harshad Sharma hiway

View GitHub Profile
@hiway
hiway / ohgodno.lua
Created February 27, 2015 10:11
Here's a script to punch a big hole thru your VPS's security and access your shell over Telegram chat… don't try this on production.
-- To use: telegram-cli -k tg-server.pub -s ohgodno.lua
--
-- Remember to watch for your telegram ID in telegram-cli, update it below.
-- This script will let you message yourself, and will ignore messages from others.
telegram_id = 1234567
message_echo = ""
function on_msg_receive (msg)
if msg.to.id == telegram_id and msg.from.id == telegram_id and msg.text ~= message_echo then
@hiway
hiway / requirements.txt
Last active September 21, 2021 07:21
Script to parse YAML files, gather information from them and then finally output to a PDF (pdf part is incomplete)
click==3.3
Pillow==2.7.0
PyYAML==3.11
reportlab==3.1.44
@hiway
hiway / socialpay.php
Created March 17, 2015 13:19
Enable SocialPay on Instamojo Payment Link using API
<?php
// https://github.com/Instamojo/instamojo-php
require "instamojo.php";
$api = new Instamojo('[API_KEY]', '[AUTH_TOKEN]',); //In live code API Keys are written here
try {
$response = $api->linkCreate(array(
'title'=>'SocialPay via PHP',
@hiway
hiway / stream_stdin.py
Created November 29, 2015 10:47
Example of reading streaming input from stdin using https://github.com/dabeaz/curio
# Example of reading streaming input from stdin
import sys
import curio
async def main():
stdin = curio.io.Stream(sys.stdin.buffer)
while stdin:
line = await stdin.read(1024)
if not line:
from functools import partial
from urllib.parse import urljoin
class RequestBuilder(object):
def __init__(self, endpoint, trailing_slash=True):
self._endpoint = endpoint
self._trailing_slash = trailing_slash
self._path = endpoint
self._params = {}
self._http_methods = ['get', 'post', 'put', 'update', 'delete']

I Adore You

Let's trace this back a bit. We did not choose who our parents would be, neither did we choose the religion nor the financial constraints. We did not get a say in what neighborhood we would spend our formative years. We did not even really pick our friends in the beginning; whoever was around became a friend. Our education was designed for a hypothetical average student and the economy that dictates our choices for profession was not designed by us. Yet, look how far we've come! All because of the choices we made after our cards were dealt to us.

We humans have risen above our own limitations time after time. From the first farmers to tame land to scientists taming nanometer sized particles and professionals moving tonnes of rocks with a little nudge to a yoke. We've made it possible for us to see what our eyes cannot see, to go where our bodies would not survive and to communicate with a huge chunk of the entire planet in the blink of an eye.

We made choices to be better at what we do, and the

@hiway
hiway / freebsd_gunicorn_rc_script
Created March 11, 2016 11:04
Run gunicorn WSGI app as a FreeBSD 10.2 service.
#!/bin/bash
. /etc/rc.subr
name="PROJECTNAME"
rcvar="PROJECTNAME_enable"
project_dir="/opt/PROJECT_DIR/"
gunicorn_command="/opt/VIRTUALENVS/PROJECT/bin/gunicorn"
@hiway
hiway / .bash_profile
Last active May 27, 2016 15:14
.bash_profile for python virtualenvwrapper using brew python (MaxOSX El Capitan)
export WORKON_HOME=$HOME/virtualenvs
export PROJECT_HOME=$HOME/Source
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
source /usr/local/bin/virtualenvwrapper_lazy.sh
@hiway
hiway / micropython-esp8266-scheduler.py
Created July 5, 2016 23:42
First draft of a rudimentary async/ await based scheduler that can run coroutines that share time by sleeping and handing over control.
import gc
import time
CLOCK_PERIOD = 0x3fffffff # ACTUAL: overflows at 1073741823 microseconds (1073.74 seconds)
# CLOCK_PERIOD = 0x3ffffff # TESTING: overflow at: 67108863 (67.10 seconds)
# CLOCK_PERIOD = 0x3fffff # IMPATIENT TESTING: overflow at: 4194303 (4.19 seconds)
MAX_TIMEOUT = CLOCK_PERIOD // 2
MAX_SECONDS = MAX_TIMEOUT // (10 ** 6) # 536.87 seconds
PLATFORM_ESP = 1
@hiway
hiway / pybble.py
Last active June 29, 2023 23:46
Python on Pebble. Yes. It works, with a bit of space to write a decent app and some heap memory to spare. AJAX works, as shown in code.
"""
pybble.py
Yup, you can run Python on your Pebble too! Go thank the good folks who
made Transcrypt, a dead-simple way to take your Python code and translate
it to *very* lean Javascript. In our case, instead of browser, we run it
on Pebble using their equally dead-simple Online IDE and Pebble.js library.
Here's a working example, it runs on a real Pebble Classic.