Skip to content

Instantly share code, notes, and snippets.

x = [0,3,2,5,4,6,1]
i=0
T=0
while i != 5:
i = i + 1
T = T + x[i]
print T
@Megabytemb
Megabytemb / utils.js
Created September 3, 2015 11:06
Human Date Difference
Date.daysBetween = function (date_now, date_future) {
// get total seconds between the times
var delta = Math.abs(date_future - date_now) / 1000;
delta_orig = delta;
// calculate (and subtract) whole days
var days = Math.floor(delta / 86400);
delta -= days * 86400;
// calculate (and subtract) whole hours
from time import sleep
while True:
print "Up Down: Green"
print "Left Right: Red"
sleep((60*5) - 60) #It will take us 1 minute to changes the lights, so 5 minutes - one minute
print "Up Down: Yellow"
print "Left Right: Red"
sleep(30) # Let People Stop
print "Up Down: Red"
app.directive('dynamicTime', ['$timeout', '$log',
function ($timeout, $log) {
return {
restrict: 'E',
scope: {
time: '=',
prefix: '@',
suffix: '@'
},
controller: function ($scope) {
@Megabytemb
Megabytemb / poke.py
Last active February 18, 2016 08:18
Poke one friend on facebook. because screw them
#!usr/bin/env/ python
# Python Script to automatically Poke people on facebook
# By Sebin Thomas
# USE AT YOUR OWN RISK
# It was written in a Hurry so no error handling whatsoever and there may be a zillion Bugs
# And it's not Safe
# THOSE WHO USE THIS CODE ARE DOING SO IN THEIR OWN RISK AND THE AUTHOR
# IS NOT ACCOUNTABLE FOR ANY DAMAGE WHATSOEVER
# Usage : poke.py Username password
import urllib2
@Megabytemb
Megabytemb / AES.ps1
Last active June 29, 2016 12:10 — forked from complex86/AES.ps1
#AES Key file export location
$KeyFile = "C:\AES.key"
#Generate Key
$Key = New-Object Byte[] 16 # You can use 16, 24, or 32 for AES
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($Key)
#write key to file
$Key | out-file $KeyFile
@Megabytemb
Megabytemb / sad logon.py
Created August 14, 2016 23:56
Some of the dirtiest logon code i've ever created.
def is_logged_in():
if flask.session.has_key("profile_complete"):
"""
For every request, we're going to make sure that the user is Authenticated with Google.
This way we can make sure that when an account is disabled in Google, this Application
immediately stops working.
Its dirty and slow, but it works.
"""
http = oauth2.http()
import email
import argparse
from bs4 import BeautifulSoup
parser = argparse.ArgumentParser()
parser.add_argument("-e", "--email", help="Path to Email file", default="example.txt")
args = parser.parse_args()
def _extractHtml(msg):
response = ""
@Megabytemb
Megabytemb / app.js
Created September 3, 2015 02:24
Using Angular Material theme colors on any element
var app = angular.module('DashboardApp', ['ngMaterial']);
var _theme;
app.config(function ( $mdThemingProvider) {
$mdThemingProvider
.theme('default')
.accentPalette('orange')
.dark();
_theme = $mdThemingProvider.theme();
@Megabytemb
Megabytemb / code.js
Last active September 18, 2018 23:46
How to use Google Analytics in Apps Script Webapps
function doGet(e) {
var salt = "Djdids((cx";
var page = HtmlService
.createTemplateFromFile('index')
page.data = {
AnalyticsUserID: getHash(salt + Session.getActiveUser().getEmail())
};
page.params = {