Skip to content

Instantly share code, notes, and snippets.

@Megabytemb
Megabytemb / code.js
Last active Sep 18, 2018
How to use Google Analytics in Apps Script Webapps
View code.js
function doGet(e) {
var salt = "Djdids((cx";
var page = HtmlService
.createTemplateFromFile('index')
page.data = {
AnalyticsUserID: getHash(salt + Session.getActiveUser().getEmail())
};
page.params = {
View SeekExtract.py
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 / sad logon.py
Created Aug 14, 2016
Some of the dirtiest logon code i've ever created.
View sad logon.py
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()
View 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 / poke.py
Last active Feb 18, 2016
Poke one friend on facebook. because screw them
View poke.py
#!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
View DynamicTime
app.directive('dynamicTime', ['$timeout', '$log',
function ($timeout, $log) {
return {
restrict: 'E',
scope: {
time: '=',
prefix: '@',
suffix: '@'
},
controller: function ($scope) {
View Traffic Lights.py
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"
@Megabytemb
Megabytemb / utils.js
Created Sep 3, 2015
Human Date Difference
View utils.js
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
@Megabytemb
Megabytemb / app.js
Created Sep 3, 2015
Using Angular Material theme colors on any element
View app.js
var app = angular.module('DashboardApp', ['ngMaterial']);
var _theme;
app.config(function ( $mdThemingProvider) {
$mdThemingProvider
.theme('default')
.accentPalette('orange')
.dark();
_theme = $mdThemingProvider.theme();
View Geoff Question
x = [0,3,2,5,4,6,1]
i=0
T=0
while i != 5:
i = i + 1
T = T + x[i]
print T