Skip to content

Instantly share code, notes, and snippets.

View jsmpereira's full-sized avatar

José Santos Martins Pereira jsmpereira

  • Clearhaus A/S
  • Denmark
View GitHub Profile
@bhollis
bhollis / blog.js.coffee
Last active July 17, 2021 08:05
A simple, made-up example of the code for a simple AngularJS blog viewer as a more detailed exploration of http://benhollis.net/blog/2014/01/17/cleanly-declaring-angularjs-services-with-coffeescript/ . Yes, I know about `$resource`, but I prefer not to use it.
app = angular.module 'BlogExample', []
# Simple controller that loads all blog posts
app.controller 'BlogCtrl', ['$scope', 'Blog', ($scope, Blog) ->
# Get all the blog posts
Blog.all().then (posts) ->
$scope.posts = posts
# Extend the $scope with our own properties, all in one big block
# I like this because it looks like declaring a class.
@atmos
atmos / heaven.md
Last active November 23, 2020 22:35
Response to a dude who asked about heaven. https://github.com/holman/feedback/issues/422

@holman got a request about our deployment system, heaven

I know it's not a high priority, but has there been any activity on open-sourcing the core Heaven gem?

There is. I've been working on extracting the non-GitHub specific parts into two gems. This first is a CLI portion called hades. The second is an HTTP API portion called heaven.

When you open source something previously used as in internal tool like Heaven, Hubot, Boxen, etc., how do you manage and hook in the parts that need to stay internal?

Normally I focus around four questions:

(defun draw-frame ()
(sdl:clear-display sdl:*black*)
(sdl:draw-box-* 0 0 100 100)
(sdl:update-display))
(sdl:with-init ()
(sdl:window 1024 768)
(sdl:with-events ()
(:quit-event () t)
(:idle ()
@elutz
elutz / controller.js
Created November 27, 2012 08:56
File Upload with AngularJS & File-Upload jQuery Plugin
function AttachmentCtrl($scope, $location, $timeout, Docs) {
$(function() {
$('#detail-form-doc').fileupload({
dataType: 'json',
url: '/angular-ib/app/fileupload?id=' + $location.search().id,
add: function(e, data) {
$scope.$apply(function(scope) {
// Turn the FileList object into an Array
for (var i = 0; i < data.files.length; i++) {
$scope.project.files.push(data.files[i]);
@hjr3
hjr3 / e-commerce.md
Created April 3, 2012 05:35
Examples of RESTful API calls for E-commerce platforms

Examples of RESTful API calls for E-commerce platforms

These examples are type 3 RESTful API requests and responses. The JSON-HAL specification is used to implement HATEOAS.

Some of the examples are based on my work as architect of the RESTful API at http://www.hautelook.com. All proprietary information has been removed.

Relevant links

http://stackoverflow.com/questions/68569/text-watermark-on-website-how-to-do-it
<style type="text/css">
#watermark {
color: #d0d0d0;
font-size: 200pt;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
position: absolute;
width: 100%;
@tstachl
tstachl / ProxyRb.rb
Created November 19, 2011 01:24
Sinatra Ruby Javascript Ajax Request Proxy
# Copyright (c) 2012, Thomas Stachl <thomas@stachl.me>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
@mcmire
mcmire / current_controller_and_action.rb
Created December 31, 2010 08:54
Hacking Padrino to store current "controller" and "action"
# Put this in lib/current_controller_and_action.rb
module Padrino
module Rendering
module InstanceMethods
private
# Override render to store the current template being rendered so we can refer to it in the view
# This works with Padrino >= 0.9.10
def render(engine, data=nil, options={}, locals={}, &block)
# If engine is a hash then render data converted to json
#!/usr/bin/env ruby
require 'pathname'
require 'yaml'
def expand(new_yaml, yaml)
yaml.keys.each do |k|
append(new_yaml, k, yaml[k])
end
end