Skip to content

Instantly share code, notes, and snippets.

View callmephilip's full-sized avatar

Philip Nuzhnyi callmephilip

View GitHub Profile
@callmephilip
callmephilip / manifest.json
Created September 15, 2014 21:50
Configuring content scripts
"content_scripts": [
{
"matches": [
"http://*/*", "https://*/*"
],
"js": [
"scripts/inject.js"
],
"css": [
"css/animate.css",
var scripts = document.querySelectorAll("head > script") || [];
var reportData = [];
for(var i=0; i<scripts.length; i++){
if(scripts[i].innerHTML){
reportData.push({
content : scripts[i].innerHTML
});
}
}
<!DOCTYPE html>
<html>
<head>
<script src="/scripts/settings.js"></script>
<script src="/scripts/archive.js"></script>
<script src="/scripts/identity.js"></script>
<script src="/scripts/ddp.js"></script>
<script src="/scripts/meteor.js"></script>
<script src="/scripts/background.js"></script>
</head>
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse){
// look at the message and see if it has report data
// extract data and look for Meteor traces
// contact app server
// adjust UI
});
// poor man's Meteorjs
// endpoint should be : ws://yourapplication.meteor.com/websocket
var Meteor = {
call : function(methodName, params, callback){
var options = {
endpoint: ApplicationSettings.meteorSocketEndpoint,
SocketConstructor: WebSocket
};
// report spotting is declared through Meteor.methods({}) on the server
Meteor.call('reportSpotting',spotting, function(err,res){});
@callmephilip
callmephilip / gist:3430537
Created August 22, 2012 23:30
[Django] requiring a view to accept particular method(s)
from django.views.decorators.http import require_http_methods
@require_http_methods(["GET", "POST"])
def my_view(request):
# I can assume now that only GET or POST requests make it this far
# ...
pass
@callmephilip
callmephilip / gist:3430847
Created August 23, 2012 00:30
[CSS] box with an inset shadow
{
background: white;
border-radius: 5px;
padding: 20px;
-moz-box-shadow: inset 0 0 5px #999;
-webkit-box-shadow: inset 0 0 6px #757575;
box-shadow: inner 0 0 5px #999;
}
@callmephilip
callmephilip / gist:3445229
Created August 24, 2012 03:47
[Python] generate UUID
import uuid
uuid.uuid1().hex
@callmephilip
callmephilip / gist:3445408
Created August 24, 2012 04:26
[Python Django] view decorator with parameters
from functools import wraps
from django.utils.decorators import available_attrs
def my_decorator(parameter_name):
def decorator(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
return view_func(request, *args, **kwargs)
return _wrapped_view