Skip to content

Instantly share code, notes, and snippets.

View woss's full-sized avatar
🛸

Daniel Maricic woss

🛸
View GitHub Profile
@woss
woss / README.md
Last active August 29, 2015 14:22 — forked from oodavid/README.md

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

@woss
woss / LocalBroadcastExampleActivity.java
Created October 10, 2015 07:59 — forked from Antarix/LocalBroadcastExampleActivity.java
Simple Example of using LocalBroadcastManager in Android
import android.app.Activity;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
@woss
woss / dropzone-directive.js
Created December 31, 2015 11:05 — forked from compact/dropzone-directive.js
AngularJS directive for Dropzone.js
/**
* An AngularJS directive for Dropzone.js, http://www.dropzonejs.com/
*
* Usage:
*
* <div ng-app="app" ng-controller="SomeCtrl">
* <button dropzone="dropzoneConfig">
* Drag and drop files here or click to upload
* </button>
* </div>
@woss
woss / sort_requirements.py
Created February 15, 2017 18:24 — forked from michaelBenin/sort_requirements.py
Sort requirements pip files or requirements.txt for python dependencies
requirements_file = 'base.pip'
requirements = open(requirements_file, 'r')
content = requirements.read().splitlines()
content = list(set(content))
content.sort(key=lambda y: y.lower())
content = '\n'.join(content)
file = open('sorted_'+requirements_file, 'w')
file.write(content)
@woss
woss / sort_requirements.py
Created February 15, 2017 18:24 — forked from michaelBenin/sort_requirements.py
Sort requirements pip files or requirements.txt for python dependencies
requirements_file = 'base.pip'
requirements = open(requirements_file, 'r')
content = requirements.read().splitlines()
content = list(set(content))
content.sort(key=lambda y: y.lower())
content = '\n'.join(content)
file = open('sorted_'+requirements_file, 'w')
file.write(content)
@woss
woss / .block
Last active May 25, 2017 11:21 — forked from mbostock/.block
Force-Directed Tree
license: gpl-3.0
@woss
woss / bitcolor.js
Created December 17, 2017 17:48 — forked from lrvick/bitcolor.js
Javascript functions for doing fast binary/hex/RGB color conversions using bitwise operations.
// convert 0..255 R,G,B values to binary string
RGBToBin = function(r,g,b){
var bin = r << 16 | g << 8 | b;
return (function(h){
return new Array(25-h.length).join("0")+h
})(bin.toString(2))
}
// convert 0..255 R,G,B values to a hexidecimal color string
RGBToHex = function(r,g,b){
@woss
woss / apollo-fetch.js
Created September 17, 2018 16:32 — forked from stubailo/apollo-fetch.js
Call a GraphQL API with apollo-fetch
const { createApolloFetch } = require('apollo-fetch');
const fetch = createApolloFetch({
uri: 'https://1jzxrj179.lp.gql.zone/graphql',
});
fetch({
query: '{ posts { title }}',
}).then(res => {
console.log(res.data);
@woss
woss / Object Flatten
Created October 5, 2019 18:02 — forked from penguinboy/Object Flatten
Flatten javascript objects into a single-depth object
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
@woss
woss / Object Flatten
Created October 5, 2019 18:02 — forked from penguinboy/Object Flatten
Flatten javascript objects into a single-depth object
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;