Skip to content

Instantly share code, notes, and snippets.

@Craga89
Craga89 / ios-version.js
Created May 29, 2012 16:39
JavaScript iOS version detection
/*
* Outputs a float representing the iOS version if user is using an iOS browser i.e. iPhone, iPad
* Possible values include:
* 3 - v3.0
* 4.0 - v4.0
* 4.14 - v4.1.4
* false - Not iOS
*/
var iOS = parseFloat(
@charlesbedrosian
charlesbedrosian / 010_copy_build_extras.js
Last active March 19, 2020 11:01
Copy build-extras to platforms/android
#!/usr/bin/env node
//goes in hooks/after_platform_add/
var fs = require('fs');
rootdir = process.argv[2],
android_dir = rootdir + '/platforms/android';
gradle_file = rootdir + '/build-extras.gradle';
dest_gradle_file = android_dir + '/build-extras.gradle';
@leotada
leotada / obfuscate_email.py
Last active July 7, 2021 14:45
obfuscate Email python
def hide_email(email):
m = email.split('@')
return f'{m[0][0]}{"*"*(len(m[0])-2)}{m[0][-1]}@{m[1]}'
# Test
print(hide_email('emailsecreto@gmail.com'))
@obeattie
obeattie / s3signurl.py
Created July 19, 2011 10:27
Quick, dirty Python script that spits out a signed url for Amazon S3
#!/usr/bin/env python
import optparse
import sys
from boto.s3.connection import S3Connection
def sign(bucket, path, access_key, secret_key, https, expiry):
c = S3Connection(access_key, secret_key)
return c.generate_url(
expires_in=long(expiry),
@stephenharris
stephenharris / readme.md
Last active April 10, 2023 06:53
Suppressing comments from git diff of .po files

How to suppress comments when performing git diff on .po files.

Taken from: http://stackoverflow.com/questions/2006351/gettext-po-files-under-version-control

Changes in the codebase can alter line numberings given in .po 'comments'. While such changes should be committed they make obsecure the actual translation changes made, and make auditing them difficult.

  1. Create /usr/local/bin/strippocomments as given in this gist.
@ipedrazas
ipedrazas / gist:2c93f6e74737d1f8a791
Created September 18, 2014 22:13
List Docker Container Names and IPs
function drips(){
docker ps -q | xargs -n 1 docker inspect --format '{{ .NetworkSettings.IPAddress }} {{ .Name }}' | sed 's/ \// /'
}
@conorbuck
conorbuck / angle-between-points.js
Created May 5, 2012 22:51
JavaScript: Find the angle between two points
var p1 = {
x: 20,
y: 20
};
var p2 = {
x: 40,
y: 40
};
@javilobo8
javilobo8 / download-file.js
Last active April 9, 2024 12:01
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@ricjcosme
ricjcosme / dump-restore
Created September 13, 2017 17:33
DUMP / RESTORE PostgreSQL Kubernetes
DUMP
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
kubectl exec [pod-name] -- bash -c "pg_dump -U [postgres-user] [database-name]" > database.sql
RESTORE
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
@ahoward
ahoward / caching-https-creds.markdown
Created June 6, 2012 21:42
Fix Username/Password prompting for github repos cloned via https scheme

github recently switched to an https scheme as the default for cloning repos. as a side effect you may suddenly be prompted for a 'Username' and 'Password' when you push where, previously, you were able to do so without typing in credentials. the solution is to cause git to cache https credentials which is easy, since git uses curl under the covers

in your home directory create a file called '.netrc', for example

/Users/ahoward/.netrc

in it put these contents