Skip to content

Instantly share code, notes, and snippets.

greg@ubuntu:/var/www/silk/lib$ git status
# On branch master
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
#
# deleted: ../config/routes.php.orig
# deleted: ../config/setup.yml.orig
# modified: ../index.php
# modified: silk/classes/class.silk_ajax.php
# modified: silk/classes/class.silk_application.php
public function editAboutMe_ajax($params) {
$form = SilkForm::create_form_start(array("remote" => "true", "url" => "/silk/mp/portfolio/saveAboutMe_ajax"));
$form .= SilkForm::create_input_textarea(array("value" => $params["description"], "cols" => "60", "name" => "description"));
$form .= SilkForm::create_input_hidden(array("name" => "id", "value" => $params["id"]));
$form .= "<br />";
$form .= silkform::create_input_submit(array("value" => "Save"));
$form .= SilkForm::create_form_end();
$this->show_layout = false;
/**
* Fills an object with posted form variables
*
* @param array Contains hash of values to load into the object (used in conjunction with SilkForm::auto_form)
*/
function fill_object_form($params) {
foreach($params as $key=>$value) {
$this->$key = $value;
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>{$title}</title>
{javascript file="lib/silk/jquery/jquery.js"}
{javascript file="lib/silk/jquery/jquery.color.js"}
{javascript file="lib/silk/jquery/jquery.silk.js"}
{stylesheet}
object(__PHP_Incomplete_Class)#3 (16) {
["__PHP_Incomplete_Class_Name"]=>
string(6) "mpUser"
["params"]=>
array(11) {
["id"]=>
string(2) "26"
["username"]=>
string(9) "braindead"
["password"]=>
<?php
class mpUser extends SilkUser {
public function __construct(){
parent::__construct();
}
public function setup() {
$this->create_has_many_association("friends", "Friend", "user_id");
$this->create_has_many_association("activity", "UserActivity", "user_id");
// $this->create_belongs_to_association("activity", "user_activity", "user_id");
$friendsActivity = orm("UserActivity")->find_all(array("join" => array("INNER JOIN silk_friends on friends.user_id = silk_user_activity.user_id"), "conditions" => array("friends.user_id = ?", $params["user_id"])));
public function editAboutMe_ajax($params) {
$this->show_layout = false;
$resp = new SilkAjax();
$this->set("params", $params);
$this->set("formType", "edit");
$resp->replace_html("#AboutMe", $this->render_partial("edit_about_me_ajax.tpl"));
return $resp->get_result();
}
@gregfroese
gregfroese / gist:4124753
Created November 21, 2012 13:04
Posting an image in RubyMotion using BubbleWrap and saving it in Rails
## RubyMotion
imageData = UIImage.UIImageJPEGRepresentation(@image_view.image, 1)
encodedData = [imageData].pack("m0")
data["image"] = encodedData
BW::HTTP.post("http://localhost:3000/upload}", {payload: data}) do |response|
if response.ok?
end
end
@gregfroese
gregfroese / jwtauth.js
Last active August 29, 2015 14:05
jwtauth.js
var rpc = require('amqp-rpc').factory({
url: "amqp://guest:guest@localhost:5672"
});
module.exports = function(req, res, next) {
var jwt = require('jwt-simple');
token = (req.body && req.body.access_token) || (req.query && req.query.access_token) || req.headers['x-access-token'];
rpc.call('profile.confirmToken', {token: token}, function(result, user, msg) {