Skip to content

Instantly share code, notes, and snippets.

View juneym's full-sized avatar

Raul Martinez Jr juneym

  • Carparts.com Inc
  • Torrance, CA
  • 04:03 (UTC -07:00)
View GitHub Profile
@juneym
juneym / slim3-pass-req-resp-to-internal-object.php
Created March 16, 2017 08:45
Slim3 | passing request and response to an internal object instance
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require '../vendor/autoload.php';
$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
$handleObj = new \My\Namespace\HelloHandler($request, $response);
@juneym
juneym / php-generator-as-coroutines.php
Last active June 22, 2016 06:37
PHP Generator as basis for co-routines
<?php
function getNextProduct($q, callable $f) {
$qptr = 0;
while (true) {
if ($qptr == count($q)) {
$qptr = 0;
}
@juneym
juneym / capture.js
Created January 9, 2016 07:08 — forked from gaspanik/capture.js
Take screenshot at single viewport size using CasperJS
var screenshotUrl = 'http://example.com/'
var casper = require("casper").create({
viewportSize: {
width: 1024,
height: 768
}
});
if (casper.cli.args.length < 1) {
@juneym
juneym / screenshots.js
Created January 9, 2016 07:04 — forked from nhoizey/screenshots.js
Take screenshots at different viewport sizes using CasperJS
/*
* Takes provided URL passed as argument and make screenshots of this page with several viewport sizes.
* These viewport sizes are arbitrary, taken from iPhone & iPad specs, modify the array as needed
*
* Usage:
* $ casperjs screenshots.js http://example.com
*/
var casper = require("casper").create();
@juneym
juneym / Castle.xml
Created December 20, 2015 09:09 — forked from kwmt/Castle.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Data>
<Series>
<id>83462</id>
<Actors>|Nathan Fillion|Stana Katic|Molly C. Quinn|Jon Huertas|Seamus Dever|Tamala Jones|Susan Sullivan|Ruben Santiago-Hudson|Monet Mazur|</Actors>
<Airs_DayOfWeek>Monday</Airs_DayOfWeek>
<Airs_Time>10:00 PM</Airs_Time>
<ContentRating>TV-PG</ContentRating>
<FirstAired>2009-03-09</FirstAired>
<Genre>|Drama|</Genre>
@juneym
juneym / Castle.xml
Created December 20, 2015 09:09 — forked from bemasher/Castle.xml
Example of parsing xml in golang.
<?xml version="1.0" encoding="UTF-8" ?>
<Data>
<Series>
<id>83462</id>
<Actors>|Nathan Fillion|Stana Katic|Molly C. Quinn|Jon Huertas|Seamus Dever|Tamala Jones|Susan Sullivan|Ruben Santiago-Hudson|Monet Mazur|</Actors>
<Airs_DayOfWeek>Monday</Airs_DayOfWeek>
<Airs_Time>10:00 PM</Airs_Time>
<ContentRating>TV-PG</ContentRating>
<FirstAired>2009-03-09</FirstAired>
<Genre>|Drama|</Genre>
@juneym
juneym / http_serv.go
Last active October 22, 2015 05:19 — forked from gotnix/http_serv.go
Share you directory via http server by golang.
package main
import (
"flag"
"fmt"
"log"
"net/http"
"strconv"
)
<?php
interface SubscriberInterface {
public static function getSubscribedEvents();
}
class BlogSubscriber implements SubscriberInterface {
public static function getSubscribedEvents() {
return array(
'blog_update' => 'Listener'
);
@juneym
juneym / client.py
Created September 25, 2015 12:17 — forked from gdamjan/client.py
Python 3.5 async/await with aiohttp, parallel or sequential
import aiohttp
import asyncio
async def get_body(url):
response = await aiohttp.request('GET', url)
raw_html = await response.read()
return raw_html
async def main():
# run them sequentially (but the loop can do other stuff in the meanwhile)
@juneym
juneym / Makefile.golang
Last active August 29, 2015 14:27 — forked from dnishimura/Makefile.golang
Makefile for Golang projects
# Makefile for a go project
#
# Author: Jon Eisen
# site: joneisen.me
#
# Targets:
# all: Builds the code
# build: Builds the code
# fmt: Formats the source files
# clean: cleans the code