Skip to content

Instantly share code, notes, and snippets.

View dagaa's full-sized avatar

Dag-Arne Alnes dagaa

View GitHub Profile
@palewire
palewire / README.md
Last active August 6, 2018 12:58
Simple COPY examples

Simple COPY examples

Two simple examples of quickly loading data into PostgreSQL with the COPY command.

  • First, loading data to a database on your own computer in localhost.sh
  • Second, loading data to a database hosted on the Internet in cloud.sh

Much more sophisticated stuff is possible. Refer to the official docs and consider adopting a wrapper like django-postgres-copy for more complicated tasks.

@8trackbattlecat
8trackbattlecat / https-instance-single.config
Last active June 16, 2021 03:37
Let's Encrypt SSL Single Instance PHP Elastic Beanstalk .ebextensions
#Do not include this file until your production certificate is working
#This config Forcing ssl will prevent lets encrypt from verifying your domain
#https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/https-singleinstance.html
Resources:
sslSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
ToPort: 443
@Dammmien
Dammmien / average.js
Last active October 3, 2019 09:06
Average of an array ES6
var average = arr => arr.reduce( ( p, c ) => p + c, 0 ) / arr.length;
average( [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] );
// 5
// transform cropper dataURI output to a Blob which Dropzone accepts
function dataURItoBlob(dataURI) {
var byteString = atob(dataURI.split(',')[1]);
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ab], { type: 'image/jpeg' });
}
@dagaa
dagaa / php_stuff
Created September 13, 2013 08:43
Some cool PHP stuff
# Built-in web server since PHP 5.4
In the command line set the path to the document root or where the code lies.
$ cd ~/public_html
$ php -S localhost:8000
-------------------------------------------------------------------------------------------
# Remove duplicate values from the array
@adililhan
adililhan / awesome-php.md
Created September 20, 2012 07:47 — forked from sineld/awesome-php.md
Awesome PHP Libraries
@RedBeard0531
RedBeard0531 / functions.js
Created February 22, 2012 20:13
Min, Max, Sum, Count, Avg, and Std deviation using MongoDB MapReduce
// derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
function map() {
emit(1, // Or put a GROUP BY key here
{sum: this.value, // the field you want stats for
min: this.value,
max: this.value,
count:1,
diff: 0, // M2,n: sum((val-mean)^2)
});
# GravitronShiftr
#
# just a simple test of ShinyCocos2d
# i could get used to this
class DemoScene < Cocos2D::Scene
include Cocos2D
def initialize
@layer = Layer.new