This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function colorSpam () { | |
var colors = ["red", "blue", "green", "orange", "purple", "yellow"]; | |
function changeColor(i) { | |
i = i < colors.length ? i: 0; | |
document.body.style.backgroundColor = colors[i]; | |
setInterval(function () {changeColor(i + 1)}, 100); | |
} | |
changeColor(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Rushy Panchal | |
# Bootstrap a new server, with either Apache or Nginx | |
# This is experimental and not production-ready | |
# I do not take any liability for any damage or problems caused by misuse | |
# This script is provided as-is, as detailed in the General Public License (GPL) version 3.0 | |
# To use: | |
# upload to your server (through SFTP) | |
# chmod +x bootstrap.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.smoothScroll = function(options) { | |
var options = jQuery.extend({offset: 0, duration: 900, easing: "swing"}, options); | |
$('html, body').stop().animate({'scrollTop': this.offset().top + options.offset}, options.duration, options.easing); | |
} | |
function anchorLinkSmoothScroll() { | |
// Smooth scroll to any clicked anchor link | |
$("a[href^=#]").click(function (event) { | |
event.preventDefault(); | |
var anchorLink = this.href.replace(this.baseURI, ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
repositories is a list of repository objects, in the form of | |
[ | |
{name: "repo A", description: "my first repository!"}, | |
{name: "repo B", description: "my second repository!"} | |
] | |
This is the same form as returned by the GitHub API: https://api.github.com/users/panchr/repos | |
query is just the search query as a string, such as "repo python my first" | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
FILTER_WORDS = ["spam", "morespam", "blahblah"] # and so forth | |
FILTER = re.compile("|".join(FILTER_WORDS)) | |
def phrasePassesFilter(word): | |
'''Checks if the phrase passes the filter''' | |
return not bool(FILTER.match(word)) # if there are no matches, FILTER.match --> None, so it passes the filter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rushy Panchal | |
// bitstring.c | |
// Provides bitstring operations in C | |
#include <math.h> | |
unsigned int countBits(unsigned int n); | |
unsigned int not(unsigned int n); | |
unsigned int rcirc(unsigned int x, unsigned int n); | |
unsigned int lcirc(unsigned int x, unsigned int n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o errexit | |
# Author: David Underhill | |
# Script to permanently delete files/folders from your git repository. To use | |
# it, cd to your repository's root and then run the script with a list of paths | |
# you want to delete, e.g., git-delete-history path1 path2 | |
if [ $# -eq 0 ]; then | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from queue_db import QueuedWriter | |
from pymongo import Connection | |
from flask import Flask | |
from json import dumps | |
def main(): | |
'''This is just an example using Flask and MongoDB/pymongo. | |
Of course, you can use any web server and any database as long as you set up the methods appropriately''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from logging.handlers import SMTPHandler | |
from flask import Flask | |
app = Flask(__name__) # configure however you normally do | |
app.debug = False | |
if not app.debug: | |
logging.basicConfig(level = logging.INFO) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rushy Panchal | |
# configure.py | |
# Initializes the server | |
import subprocess | |
def main(): | |
'''Main process''' | |
with open("nginx.conf", "w") as nginx_conf: | |
nginx_conf.write('''{{ nginx_conf }}''') |
OlderNewer