Skip to content

Instantly share code, notes, and snippets.

@maligree
maligree / robot.js
Created December 4, 2012 18:32
MALLORY
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if (robot.availableClones > 0) {
Request:
https://graph.facebook.com/oauth/authorize?scope=publish_stream%2Cuser_location%2Cuser_about_me%2C+email%2Cuser_about_me%2Cuser_birthday&response_type=code&redirect_uri=https%3A%2F%2Fsmartpds.idfederate.com%2Fapi%2Flogin%2Ffacebook%2Fredirect&display=popup&client_id=310015479050308
Response:
{
"error": {
"message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
"type": "OAuthException",
"code": 191
}
Request:
https://accounts.google.com/o/oauth2/auth?approval_prompt=auto&client_id&redirect_uri=https://smartpds.idfederate.com/api/login/google2/redirect&response_type=code&scope=https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile
Response:
Error: invalid_request
Missing required parameter: client_id
response_type=code
scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
Feb 07 18:01:31 simplesamlphp DEBUG [1bff827598] Received SAML2 Response from 'http://idp-linex.jelastic.planeetta.net:80/openam'.
Feb 07 18:01:31 simplesamlphp DEBUG [1bff827598] No certificate in message when validating against fingerprint.
Feb 07 18:01:31 simplesamlphp DEBUG [1bff827598] Found 1 certificates in SAML2_Assertion
Feb 07 18:01:31 simplesamlphp DEBUG [1bff827598] Has 1 candidate keys for validation.
Feb 07 18:01:31 simplesamlphp DEBUG [1bff827598] Validation with key #0 succeeded.
Feb 07 18:01:31 simplesamlphp DEBUG [1bff827598] Filter config for http://idp-linex.jelastic.planeetta.net:80/openam->http://saml-cake.aws.af.cm/simplesaml/module.php/saml/sp/metadata.php/default-sp: array ( 0 => sspmod_core_Auth_Process_GenerateGroups::__set_state(array( 'generateGroupsFrom' => array ( 0 => 'eduPersonAffiliation', ), 'priority' => 60, )), 1 => sspmod_core_Auth_Process_AttributeAdd::__set_state(array( 'replace' => false, 'attributes' => array ( 'groups' =>
@maligree
maligree / sigit.php
Created April 23, 2013 14:51
A down-to-earth reference implementation of the wicked OAuth signing process. Without a token secret.
<?php
/*
* No-frills OAuth 1.0 request signing code.
* For reference see:
* https://dev.twitter.com/docs/auth/creating-signature
*/
function get_sig($uri, $c_key, $c_secret) {
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'YOUR_APP_ID', // App ID from the app dashboard
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel file for x-domain comms
status : true, // Check Facebook Login status
xfbml : true // Look for social plugins on the page
});
@maligree
maligree / gist:5998561
Created July 15, 2013 09:10
Dumb stress testing insights:
**************** 15/20, Shotgun ****************
~ » python stress.py maligree@WickedArtistry
[#] Firing up.
[*] Will do 15 simultaneous, 20-request series.
--- HTTP 200, took 7.23 s
--- HTTP 200, took 7.23 s
--- HTTP 200, took 7.24 s
--- HTTP 200, took 7.21 s
--- HTTP 200, took 7.26 s
@maligree
maligree / gist:6113756
Created July 30, 2013 15:03
How it happened.
# open up the DB in the console
$ sqlite3 storage/regroup.db
# set output mode to `insert`, this returns SQL
sqlite3> .mode insert
# set output to file
sqlite3> .out /home/jacek/apps.sql
# run the query, effectively creating an SQL dump of the data
sqlite3> select * from apps;
# change output file (required, see sed lines)
sqlite3> .out /home/jacek/resources.sql
ps aux | grep python
kill <wszystko co z pythonem>
cd portal-sql
source venv/bin/activate
nohup python manage.py runserver 0.0.0.0:9876 &
@maligree
maligree / gist:6448505
Created September 5, 2013 10:33
kod z multiprocessing
def cpu_count():
'''
Returns the number of CPUs in the system
'''
if sys.platform == 'win32':
try:
num = int(os.environ['NUMBER_OF_PROCESSORS'])
except (ValueError, KeyError):
num = 0
elif 'bsd' in sys.platform or sys.platform == 'darwin':