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 numpy as np | |
import matplotlib.pyplot as plt | |
counts = [10, 8, 6, 14] | |
weights = np.ones_like(counts) / float(len(counts)) | |
plt.figure(figsize=(10, 5)) | |
plt.hist(counts, bins=range(1, max(counts)+2), align='left', weights=weights) | |
plt.xticks(range(1, max(counts)+1)) | |
plt.show() |
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
@app.route('/', methods=['GET'], defaults={'var': 'default'}) | |
@app.route('/<string:var>', methods=['GET']) | |
def page(var): | |
# do stuff with the given var or default | |
return render_template('page.html', var=var) |
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
select schemaname||'.'||tablename | |
from pg_tables | |
where has_table_privilege ( | |
'~~user_name~~', | |
schemaname||'.'||tablename, | |
'~~permission_type~~' | |
) | |
and schemaname not in ( | |
'pg_catalog', | |
'information_schema' |
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
select | |
schemaname, | |
tablename, | |
pg_size_pretty(size) as size_pretty, | |
pg_size_pretty(total_size) as total_size_pretty | |
from ( | |
select | |
*, | |
pg_relation_size(schemaname ||'.'|| tablename) as size, |
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
git fetch origin 8fd8e58c2599a9d31f9ca8cad1fdb7524dc794e5:refs/remotes/origin/~~branch_name~~ |
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
case extract(isodow from ~~date~~) | |
when 1 then 'Mon ' || cast(~~date~~ as date) | |
when 2 then 'Tue ' || cast(~~date~~ as date) | |
when 3 then 'Wed ' || cast(~~date~~ as date) | |
when 4 then 'Thu ' || cast(~~date~~ as date) | |
when 5 then 'Fri ' || cast(~~date~~ as date) | |
when 6 then 'Sat ' || cast(~~date~~ as date) | |
when 7 then 'Sun ' || cast(~~date~~ as date) | |
end date |
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
/*dragon*/var b=X=Y=T=L=0;document.addEventListener("click",function(a){a.preventDefault()},!0);document.addEventListener("mousedown",c);document.addEventListener("touchstart",c);function c(a){a.preventDefault();a.target!==document.documentElement&&a.target!==document.body&&(b=Date.now(),a.target.setAttribute("data-drag",b),a.target.style.position="relative",T=a.target.style.top.split("px")[0]||0,L=a.target.style.left.split("px")[0]||0);X=a.clientX||a.touches[0].clientX;Y=a.clientY||a.touches[0].clientY}document.addEventListener("mousemove",d);document.addEventListener("touchmove",d);function d(a){if(""!==b){var e=document.querySelector('[data-drag="'+b+'"]');e.style.top=parseInt(T)+parseInt((a.clientY||a.touches[0].clientY)-Y)+"px";e.style.left=parseInt(L)+parseInt((a.clientX||a.touches[0].clientX)-X)+"px"}}document.addEventListener("mouseup",f);document.addEventListener("touchend",f);function f(){b=""}document.addEventListener("mouseover",g);function g(a){a.target.style.cursor="move";a.target.style.boxShado |
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
# Visualise given word embeddings | |
# words is a list of words | |
# data is the vector representation of each word | |
# Train the algorithm | |
from sklearn.manifold import TSNE | |
vis_algo = TSNE(random_state=0, verbose=10, init='pca', n_iter=200) | |
vis = vis_algo.fit_transform(data) | |
# Plot the resulting visualisation |
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 <AppKit/AppKit.h> | |
NSRunningApplication* frontApp = [[NSWorkspace sharedWorkspace] frontmostApplication]; | |
pid_t pid = [frontApp processIdentifier]; | |
// fprintf(stdout, "%s\n", [[NSString stringWithFormat:@"%ld", (long)pid] UTF8String]); | |
// fflush(stdout); |
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
#include <CoreFoundation/CoreFoundation.h> | |
AXError rtn = AXUIElementCopyAttributeValue(someApp, someAttribute, (CFTypeRef *)&someRef); | |
if (rtn == kAXErrorSuccess) { | |
printf("\nSuccess"); | |
} else if (rtn == kAXErrorInvalidUIElement){ | |
printf("\nInvalid UI Element"); | |
} else if (rtn == kAXErrorIllegalArgument) { | |
printf("\nIllegal argument"); | |
} else if (rtn == kAXErrorCannotComplete) { | |
printf("\nCannot complete"); |