Skip to content

Instantly share code, notes, and snippets.

@rkrishnasanka
rkrishnasanka / new_gist_file.m
Last active December 21, 2015 22:39 — forked from AhmedKammorah/new_gist_file
Async operations iOS
dispatch_queue_t queue = dispatch_get_global_queue(
DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
//any thing
});
//ref
void explode(String message)
{
int count = 0;
do
{
commaPosition = message.indexOf(':');
if(commaPosition != -1)
{
Serial.println( message.substring(0,commaPosition));
#include <Servo.h>
Servo servo1;
Servo servo2;
float theta1;
float theta2;
int pot1 = 0;
int pot2 = 1;
void setup() {
int buf = 0;
int xcoordinate = 0;
int ycoordinate = 0;
void setup()
{
// start serial port at 9600 bps and wait for port to open:
Serial.begin(115200);
}
@rkrishnasanka
rkrishnasanka / PYNN.py
Created March 14, 2014 08:07
Python Neural Network with back propagator
# Back-Propagation Neural Networks
#
# Written in Python. See http://www.python.org/
# Placed in the public domain.
# Neil Schemenauer <[email protected]>
import math
import random
import string
@rkrishnasanka
rkrishnasanka / revenge.py
Last active August 29, 2015 13:57
Email Bomber Script for taking revenge on friends
import urllib
import smtplib
import time
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from random import randint
def sendemail(session,me,you,subject,html):
# Create message container - the correct MIME type is multipart/alternative.
# Written by Raul Aguaviva as an exercise
# beware not optimized for speed :-)
from struct import *
import math
zigzag = [0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 48, 41, 34,
27, 20, 13, 6, 7, 14, 21, 28,
@rkrishnasanka
rkrishnasanka / CRC.c
Created May 9, 2014 09:27
CRC Implementation for the Reaction Wheels
#define POLY 0x8408 /* bits reversed for LSB-first */
unsigned short crc = 0xffff;
while (len-- > 0) {
unsigned char ch = *bufp++;
for (i = 0; i < 8; i++) {
crc = (crc >> 1) ˆ ( ((ch ˆ crc) & 0x01) ? POLY : 0 );
ch >>= 1;
}
}
Walter Bright's MEM Package
---------------------------
PREFACE:
--------
The files, MEM.H and MEM.C which constitute the MEM package were originally
published in the March-April 1990 edition of Micro Cornucopia magazine, now
sadly out of print. The files as they appear in SNIPPETS have been edited
@rkrishnasanka
rkrishnasanka / numpytest.py
Last active October 24, 2018 13:58
Numpy Cheat sheet
import numpy as np
def run():
# create a column vector
col_vec = np.array([[1], [2]])
print "column vector"
print col_vec
# create a row vector
row_vec = np.array([[1, 2]])