Skip to content

Instantly share code, notes, and snippets.

View marcellodesales's full-sized avatar

Marcello DeSales marcellodesales

View GitHub Profile
@bewest
bewest / .gist.markdown
Last active December 20, 2015 16:09
use node restify to handle mime body uploads

Use node to handle file upload

Edit
# https://gist.github.com/6159923.git
gist=git@gist.github.com:6159923.git

git clone $gist blip_upload
# OR
git remote add origin $gist
@dbodyas
dbodyas / decimal.js
Created February 12, 2012 15:30
JavaScript Get Unicode char as decimal
/*
Sometimes, unicode symbols that have to be inserted in an HTML page should be escaped.
For example, everybody know, that’s “&” should be escaped as “&”, ” ” as “ ” and so on.
But what, if you should insert symbol, that you never used before. So you don’t know how it should be present or escaped.
Code below, helps you to get valid decimal unicode for appropriate symbol.
*/
function getCharAsDecimalUTF8(char){
var getUTF8 = escape(char);
console.log("&#" + parseInt(getUTF8.substring(getUTF8.match(/\%u/) !== null ? 2 : 1), 16) + ";");
}
@proffalken
proffalken / Dockerfile
Created January 25, 2017 14:56
Jenkins Blue Ocean Python Development
FROM jenkinsci/blueocean:latest
USER root
RUN apk add --no-cache --update \
python \
python-dev \
py-pip \
build-base \
&& pip install virtualenv \
#!/bin/bash
# Description: This script spins up a multi node Docker Swarm w/ Docker
# Networking and Consul discovery w/ Registrator
# Author: Ryan C Koch
# ryanckoch@gmail.com
# Usage: bash docker-playground.sh usage
PLAYGROUND_NAME="docker-playground"
CONSUL_IMAGE="progrium/consul"
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u74-b02/jdk-8u74-linux-x64.rpm"
sudo yum -y localinstall jdk-*.rpm
rm -fR jdk-*.rpm
/usr/sbin/alternatives --config java
# install JCE 8
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip"
unzip jce_policy-8.zip
mv /usr/java/default/jre/lib/security/local_policy.jar /usr/java/default/jre/lib/security/local_policy.jar.backup
@hasufell
hasufell / Playground.hs
Last active November 28, 2021 04:56
Plutus Playground Smart Contract
import Control.Monad (void)
import Data.Aeson (FromJSON, ToJSON)
import qualified Data.Text as T
import GHC.Generics (Generic)
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx
import Language.PlutusTx.Prelude
import Ledger
import qualified Ledger.Ada as Ada
import qualified Ledger.Constraints as Constraints
@and-pete
and-pete / Dockerfile
Created August 30, 2020 13:08
Multi-Stage Docker Build for a Haskell (Stack) Project
# The below is a combination of the following two things:
# 1) This article + corresponding Gist: https://medium.com/permutive/optimized-docker-builds-for-haskell-76a9808eb10b
# 2) This Reddit comment in response to the above:
# - https://www.reddit.com/r/haskell/comments/cl5uod/optimized_docker_builds_for_haskell/evuzccm/
# It is a multi-stage Docker build with 3 stages: 1) dependencies, 2) build, and 3) deploy
# -------------------------------------------------------------------------------------------
# STAGE 1: Dependencies
# -------------------------------------------------------------------------------------------
FROM haskell:8.10.2 as dependencies
@EwanDawson
EwanDawson / regex-capture.groovy
Created April 17, 2012 16:09
Idiomatic regex group capturing in Groovy
// Using Matcher object returned by =~ operator
matcher = "Hello world v1.01" =~ /.* v(\S*)/
if (matcher.matches()) version = matcher[0][1]
assert version == "1.01"
// We can make this a little tidier using the 'with' method
version = ("Hello world v1.01" =~ /.* v(\S*)/).with { matches() ? it[0][1] : null }
assert version == "1.01"
@imbradbrown
imbradbrown / upload-ssec.sh
Last active November 30, 2022 06:20
Uploading to Amazon S3 from curl with Server Side Encrpytion - Customer Provided Key used. Note that this uses the Amazon Access Keys which should be used with care.
#!/bin/bash
## file to upload.
S3_UPLOAD_FILE=some/path/file.txt
## Specify the bucket name here. This can be found in the S3 console
S3_BUCKET=bucket name here
## The desired path relative to the root of the bucket. All folders must be forward slash '/' separated
S3_DESTINATION_FILE=folder/folder2/file.txt
@nateware
nateware / s3update.py
Last active February 1, 2023 22:07
Check local files vs what's on S3, and upload any that have changed.
#!/usr/bin/env python
# Compare a file on S3 to see if we have the latest version
# If not, upload it and invalidate CloudFront
import fnmatch
import os
import boto
import pprint
import re