Skip to content

Instantly share code, notes, and snippets.

View Radagaisus's full-sized avatar

Almog Melamed Radagaisus

View GitHub Profile
@Radagaisus
Radagaisus / nginx.conf
Created December 31, 2014 07:39
node.js proxy in nginx w/ https
http {
upstream node_server {
server 127.0.0.1:2222;
}
server {
listen 443 ssl;
server_name example.com;
ssl on;
@Radagaisus
Radagaisus / sign_user.php
Last active August 29, 2015 14:07
Captain Up User Integration - Signing a User Object in PHP
<?php
// Signs a user object with your API secret.
// See: https://captainup.com/help/javascript/user-integration
//
// @param secret - {String} Your Captain Up API secret
// @param user - {Associative Array} the user dictionary
// @return {String} the signed user string
function sign_user($secret, $user) {
// Remove all `null`, `undefined`, arrays and objects from the object
@Radagaisus
Radagaisus / user_read.js
Last active August 29, 2015 14:05
Tracking a user page read action
// Asynchronous wrapper around Captain Up, code will run once Captain Up has loaded.
captain.up(function() {
// Periodically test if the user has read the page
setInterval(function(){
// You need to implement `user_read_the_page` by yourself, maybe as a check
// that the user scrolled to the bottom? Or spent at least a minute on the page?
if (user_read_the_page()) {
// Track the action with Captain Up, remember to configure the action settings for it
// by creating a new 'read' action in your admin panel.
captain.action('read', {
@Radagaisus
Radagaisus / coffee_script_json.rb
Created July 16, 2014 00:02
A Sprockets Engine to write valid JSON in CoffeeScript
# The CoffeeScriptJSON module is a Sprockets engine that can be used to write
# JSON files in CoffeeScript.
#
# This CoffeeScript:
#
# # whatever.json.coffee_json
# hello: 'world!'
#
# Will be compiled down to:
#
@Radagaisus
Radagaisus / sign_up.js
Created May 18, 2014 04:11
Open the Captain Up Sign Up Modal
// Asynchronous wrapper to ensure Captain Up has loaded
captain.up(function() {
//open the sign up modal
captain.open_sign_up_modal();
});
@Radagaisus
Radagaisus / hud.js
Last active August 29, 2015 13:59
Hide and Show the Captain Up HUD
// Asynchronous wrapper, the code will only run after Captain Up has loaded
captain.up(function() {
// Maximize the HUD
captain.hud.maximize();
// Minimize the HUD
captain.hud.minimize();
});
@Radagaisus
Radagaisus / minimize_hud.js
Created March 19, 2014 20:41
How To Minimize the Captain Up HUD
// Asynchronous wrapper around the function, to make sure Captain
// Up has loaded completely.
captain.up(function() {
// Minimize the HUD
captain.hud.minimize();
});
@Radagaisus
Radagaisus / customizing_points_names.js
Created March 19, 2014 18:02
How To Customize the Name of Points in Captain Up
// Asynchronous wrapper around the function, to make sure Captain
// Up has loaded completely.
captain.up(function() {
// Set the points string
captain.l.points = "XP";
// Set the shorthand name
captain.l.shorthand_points = "XP";
});
@Radagaisus
Radagaisus / captain.user.js
Last active August 29, 2015 13:56
How to get user information from Captain Up
// Used as a wrapper to make sure Captain Up has loaded on the page
captain.up(function() {
// `captain.player` holds all the information about the users, including anonymous users information
user_details = captain.player
// Do whatever you want with the data, maybe send it to your server side?
$.ajax({type: 'POST', url: 'http://mysite.com/users/', data: captain.player})
})
@Radagaisus
Radagaisus / minimized_hud.js
Created November 11, 2013 11:41
How to minimize the Captain Up HUD from the get go.
<script>
captain.up(function() {
captain.hud.minimize()
});
</script>