Skip to content

Instantly share code, notes, and snippets.

View stephanelpaul's full-sized avatar
🌍

Stephane Leandre Paul stephanelpaul

🌍
View GitHub Profile
@anotherjesse
anotherjesse / relay.app
Created March 23, 2010 22:42
tcp relay in erlang
{application, relay,
[{description, "relay"},
{vsn, "0.01"},
{modules, [
relay_app,
relay_listener,
relay_sup,
relay_worker
]},
{registered, []},
@jordanorelli
jordanorelli / error_handling.go
Created November 28, 2012 18:00
this error handling pattern isn't obvious at first
func f() error {
// might return an error
}
func somethingElse() {
switch err := f(); err {
case mgo.ErrNotFound:
// a specific error that is recoverable
case nil:
// no error occurred. Usually this is just a break statement.
@implementation BroadcastTableViewController
// ...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
// ...
cell.dateLabel.text = [NSDateFormatter localizedStringFromDate:object.createdAt
dateStyle:NSDateFormatterMediumStyle
timeStyle:NSDateFormatterShortStyle];
cell.ownerLabel.hidden = ![[(PFUser *)object[@"owner"] objectId] isEqual:[[PFUser currentUser] objectId]];;
return cell;
Parse.Cloud.define("NearByAds", nearByAds);
Parse.Cloud.define("myAds", myAds);
var locationUtil = require('cloud/latlon.js');
/*
* limit is kInitialObjectsPerPageNum(100)
* oredered by descending adDate and createdAt
* kSpecialPropertyKeyApproved(approved) is YES
* kSpecialPropertyKeyDeleted(deleted) is NO
Parse.Cloud.define("loadChannelsFromDate", function(request, response) {
var fromDate = request.params.fromDate;
var toDate = request.params.toDate;
var count = request.params.count;
var query = new Parse.Query("archupObject");
query.limit = count;
if(fromDate){
query.greaterThan("updatedAt", fromDate);
@mikevansnell
mikevansnell / invite.js
Last active October 22, 2018 21:04
Parse.com cloudcode sample that enables one user to invite another user, and immediately returns the new user object so that you can do something with it (e.g. start associating objects with it).
// in invite.js module:
exports.inviteUser = function(creatingUser,email,tempPass,response)
{
"use strict";
if (!tempPass) {
tempPass = genRandomPass();
}
var user = new Parse.User();
user.set ("username", email);
@martijnthe
martijnthe / menu_app.c
Created May 19, 2013 01:10
MenuLayer code fragment
#define BUFFER_SIZE 25
static const uint8_t s_music_launcher_icon_pixels[] = {
0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x01, 0x00, 0xff, 0x3f, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, /* bytes 0 - 16 */
0x7f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x18, 0x00, 0x7f, 0x00, 0x1f, 0x00, /* bytes 16 - 32 */
0x7f, 0xf0, 0x1f, 0x00, 0x7f, 0xfc, 0x1f, 0x00, 0x7f, 0xfc, 0x1f, 0x00, 0x7f, 0xfc, 0x1f, 0x00, /* bytes 32 - 48 */
0x7f, 0xfc, 0x1f, 0x00, 0x7f, 0xfc, 0x1f, 0x00, 0x7f, 0xfc, 0x1f, 0x00, 0x7f, 0xfc, 0x1f, 0x00, /* bytes 48 - 64 */
0x7f, 0xfc, 0x1f, 0x00, 0x7f, 0xfc, 0x1f, 0x00, 0x7f, 0xfc, 0x00, 0x00, 0x7f, 0x7c, 0x00, 0x00, /* bytes 64 - 80 */
0x03, 0x3c, 0x00, 0x00, 0x01, 0x3c, 0x00, 0x00, 0x00, 0x3c, 0x80, 0x00, 0x00, 0x3c, 0xc0, 0x00, /* bytes 80 - 96 */
@veer66
veer66 / user.go
Created November 4, 2013 10:30
User management (incomplete)
package main
import (
"crypto/rand"
"crypto/sha1"
"code.google.com/p/go.crypto/pbkdf2"
"bytes"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
)
@jystewart
jystewart / places_of_interest.go
Created November 5, 2013 22:44
Very early proof of concept golang implementation of the GOV.UK Imminence API
package main
import (
"encoding/json"
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"net/http"
)
@polds
polds / mgo_example.go
Created November 11, 2013 10:25
Mgo Example
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"time"
)
type Person struct {