Skip to content

Instantly share code, notes, and snippets.

View cyberwombat's full-sized avatar
🙄
Coding away the moments that make up a dull day

Yashua cyberwombat

🙄
Coding away the moments that make up a dull day
View GitHub Profile
@cyberwombat
cyberwombat / CORS Configuration
Created November 1, 2012 19:18
JQuery file upload plugin (blueimp) with NodeJs Express3 directly to Amazon S3 with public access
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
@cyberwombat
cyberwombat / imagemagick.js
Created November 13, 2012 16:30
Fix for NodeJS imagemagick module not parsing IM identify output
function parseIdentify(input) {
var lines = input.split("\n"),
prop = {},
props = [prop],
prevIndent = 0,
indent = 0,
indents = [indent],
currentLine, comps;
lines.shift(); //drop first line (Image: name.jpg)
@cyberwombat
cyberwombat / gist:5321157
Created April 5, 2013 17:41
Jitsu error
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error: There was an error while attempting to deploy the app
error:
error: Error spawning drone: no matching engine found
error: Repository configuration
error:
error: This type of error is usually a user error.
error: Error output from Haibu:
error:
@cyberwombat
cyberwombat / gist:5321180
Created April 5, 2013 17:44
package.json
{
"name": "gonegreen",
"domains": [
"gonegreenstore.com",
"www.gonegreenstore.com"
],
"version": "0.0.0-69",
"dependencies": {
"express": ">= 3.0.0rc2",
"passport": "*",
@cyberwombat
cyberwombat / preview.js
Created May 25, 2016 19:36
Angular delayed image load directive
/*
* Angular directive to insert an image from a source that may require a few seconds
* to become available such as a thumb created by server to AWS S3.
* This directive checks if the image yields an error, if so it will loop a HEAD request
* every intevrval (default to 500ms, 5 times), If that fails then it will jus use the
* fallback image
* This directive will only peform an HTTP request when the initial loading image fails
*/
angular.module('app').directive('preview', function(stickerService, $http, $interval) {
return {
@cyberwombat
cyberwombat / bootstrap-4.0.0-alpha.3.min.css
Created August 20, 2016 07:29
Bootstrap 4 alpha with Flex
/*!
* Bootstrap v4.0.0-alpha.3 (http://getbootstrap.com)
* Copyright 2011-2016 The Bootstrap Authors
* Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*//*! normalize.css v4.0.0 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress{vertical-align:baseline}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit}b,strong{font-weight:bolder}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relati
@cyberwombat
cyberwombat / test.php
Last active August 30, 2016 08:12
preg_replace
<?php
$html =
"<div class=\"row home-pg-feed-item pl0 pr0 ml0 mr0\" data-type=\"video\">" .
"<div class=\"col-lg-4 col-xs-4 pl0\">" .
"<a href=\"/clinical-dialogue.php?v={{ url }}\"><img src=\"{{ thumb-sm }}\" alt=\"img\"/></a>" .
"</div>" .
"<div class=\"col-lg-8 col-xs-8 pr0 \">" .
"<h4 class=\"mb5\">{{ title }}</h4>" .
"<a href=\"/clinical-dialogue.php?v={{ url }}\" class=\"watch-link\">Watch the video</a>" .
"<p>{{ summary }}</p>" .
@cyberwombat
cyberwombat / api.js
Created November 13, 2016 23:28
Walmart API authentication in Node
import { createSign, randomBytes } from 'crypto'
import axios from 'axios'
import { resolve } from 'url'
const PK_HEADER = '\n-----BEGIN PRIVATE KEY-----\n'
const PK_FOOTER = '\n-----END PRIVATE KEY-----\n'
const BASE_URL = 'https://marketplace.walmartapis.com/'
const WALMART_CONSUMER = "b68d2a72....";
// Find all files which contain 'blah' from current dir
find . -type 'f' -exec grep -H 'blah' {}\;
@cyberwombat
cyberwombat / gist:f2b8e15618f732ee543e95efe34a28bd
Last active October 24, 2017 21:29
4xx handling with various HTTP client libs for node
// request-promise-native
const body = request({ url: url, json: true })
const res = await t.throws(body);
console.log(res.error)
// node-fetch
const body = await fetch(url)
console.log(await body.json())