Skip to content

Instantly share code, notes, and snippets.

Josip Delic delijati

  • Potsdam (Berlin)
Block or report user

Report or block delijati

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Dockerrun.aws.json.template
{
"AWSEBDockerrunVersion": "1",
"Authentication": {
"Bucket": "bucket_name",
"Key": "docker/dockercfg"
},
"Image": {
"Name": "company/<image>"
},
"Ports": [
@delijati
delijati / dump.py
Last active Apr 17, 2019
dump all models when load sqlalchemy
View dump.py
import os
import json
import hashlib
import datetime
from database import db
from sqlalchemy import event
def literal_sql(context):
@delijati
delijati / orm_example.js
Created Apr 5, 2019
Knex objection ORM
View orm_example.js
'use strict';
// $ npm install knex objection sqlite3
const {Model} = require('objection');
const knex = require('knex')({
client: 'sqlite3',
connection: {
filename: './db.sqlite'
},
View main.py
# air on higher value squares will try to flow to lower value squares
# a square can only hold a certain amount of air ( Depends on square value
# ). If square is full, air will not flow into it.
import sys
import pygame
import random
from noise import pnoise2
View spot_price.py
# python spot_price.py g2.2xlarge
import sys
import boto3
import datetime
def main(argv):
if len(argv) < 2:
print("No instance provided!")
sys.exit()
View yar_log_dump.sh
#!/bin/bash
set -x
LOCAL_DIR=/home/hadoop/yarn_logs
mkdir $LOCAL_DIR
for row in $( yarn application -appStates ALL -list | awk '/application_/{print $1 "," $2}' )
do
fields=($(echo $row | tr "," "\n"))
yarn logs -applicationId ${fields[0]} > $LOCAL_DIR/yarn_${fields[0]}_${fields[1]}.log
@delijati
delijati / s3parse.py
Created Mar 8, 2018
S3 bucket path parser
View s3parse.py
import unittest
import os
from urllib.parse import urlparse
class S3Parse(object):
def __init__(self, uri):
self.uri = uri
self.parsed = urlparse(uri)
@delijati
delijati / flatdata.py
Created Sep 29, 2017
dataset + flatdict
View flatdata.py
import flatdict
values = {'foo': {'bar': {'baz': 0,
'qux': 1,
'corge': 2},
'grault': {'baz': 3,
'qux': 4,
'corge': 5}},
'garply': {'foo': 0, 'bar': 1, 'baz': 2, 'qux': {'corge': 3}}}
flat = flatdict.FlatDict(values)
@delijati
delijati / build.py
Last active Nov 25, 2016
virtualenv + pip self deployed
View build.py
from __future__ import print_function
import sys
import shutil
import os
import subprocess
is_win = (sys.platform == 'win32')
req_file = "req.txt"
home_dir = os.path.dirname(os.path.abspath(__file__))
View fb-trick-bookmark.js
javascript: (function (){ var scripts = document.getElementsByTagName('script'); var friendsList; for (var i = 0; i < scripts.length; i++) { var script = scripts[i]; if (script.innerHTML.indexOf('InitialChatFriendsList') > -1) { var friendsListString = script.innerHTML.split('"InitialChatFriendsList",[],{"list":')[1].split(',"groups"')[0]; friendsList = JSON.parse(friendsListString); console.log('friendsList:', friendsList); break; } } var html = friendsList.map(function(id, i){ id = id = id.split('-')[0]; var url = 'http://graph.facebook.com/' + id + '/picture?type=normal'; return '<a target="_blank" href="https://www.facebook.com/' + id + '"><img src="' + url + '"></a>'; }).join('\n'); var css = '<style> a { display: inline-block; margin: 7px; } img { max-width: 70px; max-height: 70px; vertical-align: top; } </style>'; open('data:text/html, <html>' + css + html + '</html>'); }());
You can’t perform that action at this time.