Skip to content

Instantly share code, notes, and snippets.

View piepieninja's full-sized avatar

Caleb Adams piepieninja

View GitHub Profile
@piepieninja
piepieninja / sqaure.cu
Created April 21, 2018 02:19
Simple CUDA example on how to make and call a kernel for parallel execution
///////////////////////////////////////////////////////////////////////////
// Example code from the Udacity tutorial on CUDA //
// Link to the video here: https://www.youtube.com/watch?v=GiGE3QjwknQ //
// TO COMPILE: $ nvcc -o square square.cu //
///////////////////////////////////////////////////////////////////////////
//
// NOTES:
// * Device: is the term of the GPU
// * Host: is the term of the CPU
@piepieninja
piepieninja / auth.py
Created March 31, 2017 05:15 — forked from velocityzen/auth.py
This script take pictures from directory and post it to tumblr blog and then delete it. Tumblr API v2! This example for oath file upload.
import urlparse
import oauth2 as oauth
consumer_key = ''
consumer_secret = ''
request_token_url = 'http://www.tumblr.com/oauth/request_token'
access_token_url = 'http://www.tumblr.com/oauth/access_token'
authorize_url = 'http://www.tumblr.com/oauth/authorize'
@piepieninja
piepieninja / reverser.cpp
Last active October 10, 2016 14:17
Linked List Reverser
#include <iostream>
using namespace std;
struct node {
int data;
struct node* next;
};
void push(struct node** head_ref, int new_data){
@piepieninja
piepieninja / JustDoIt.sh
Last active May 1, 2023 11:59
Just Do It for mac.
#!/usr/bin/env bash
say "Do it
Just do it
Don't let your dreams be dreams
Yesterday you said tomorrow
@piepieninja
piepieninja / snow.sh
Created October 8, 2015 12:59
Snow and snowflakes will fall inside your terminal. Testing using tput
# An example of how to write to the terminal without a constant clear
#!/bin/bash
LINES=$(tput lines)
COLUMNS=$(tput cols)
declare -A snowflakes
declare -A lastflakes
clear
@piepieninja
piepieninja / NSlookup.py
Created October 8, 2015 12:56
Short Name Server look up. I'll be honest I was competing with a friend to see who could get the shortest one, so some parts of this do not work in all cases.
#!/usr/bin/env python
import socket, sys, random
DNS_IP = sys.argv[1][1:]
DNS_NAME = sys.argv[2]
MSG = '\xDB\x42\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00'
names = DNS_NAME.split('.')
for s in names:
MSG += chr(len(s)) + s
MSG = '\x00\x00\x01\x00\x01'
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@piepieninja
piepieninja / echoserver.rb
Created October 8, 2015 12:53
Simple UDP server that echos written in Ruby
#!/usr/bin/env ruby
# Caleb Adams
# echoServer!
require 'socket'
# test for inputs
if (ARGV.length != 1)
abort("please enter the port number after the program")
end
# get the port number
port = ARGV[0]
@piepieninja
piepieninja / shelldraw.sh
Created October 8, 2015 12:51
Testing bash/shell script drawing using tput cup
# just testing
clear
echo %n
LINES=$(tput cols)
COLUMNS=$(tput lines)
tput cup 0 0
echo "X"
@piepieninja
piepieninja / whoisup.sh
Created October 8, 2015 12:49
Simple bash/shell script to tell what IP's are up on your LAN
for ip in $(seq 1 254); do ping -c 1 192.168.1.$ip>/dev/null; [ $? -eq 0 ] && echo "192.168.1.$ip UP" || : ; done
@piepieninja
piepieninja / dnsProxy.py
Created October 8, 2015 12:46
Super Short DNS Proxy in Python
#!/usr/bin/env python
import socket, sys, struct
UDP_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
UDP_sock.bind(("127.0.0.1", int(sys.argv[1])))
UDP_data, UDP_addr = UDP_sock.recvfrom(1024)
TCP_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
TCP_sock.connect((sys.argv[2][1:], 53))
TCP_sock.send(struct.pack("!H", len(UDP_data)) + UDP_data)
TCP_data = TCP_sock.recv(1024)
UDP_sock.sendto(TCP_data[2:], UDP_addr)