Skip to content

Instantly share code, notes, and snippets.

View jperelli's full-sized avatar
🏄‍♂️
Hacking for surfvival

Julián Perelli jperelli

🏄‍♂️
Hacking for surfvival
View GitHub Profile
# Sourced from https://github.com/anirbankonar123/CorrosionDetector/blob/master/generate_tfrecord.py
"""
Usage:
# From tensorflow/models/
# Create train data:
python3 generate_tfrecord.py --csv_input=data/train_labels.csv --output_path=data/train.record
# Create test data:
python3 generate_tfrecord.py --csv_input=data/test_labels.csv --output_path=data/test.record
"""
from __future__ import division
@jperelli
jperelli / store-config.js
Created April 4, 2017 11:16
Reactotron + redux + react-native configuration
import Reactotron from 'reactotron-react-native'
import { reactotronRedux } from 'reactotron-redux'
var store;
if (__DEV__) {
Reactotron
.configure({ name: 'VTX-sharepoint' })
.use(reactotronRedux())
.connect()
@jperelli
jperelli / gist:79451c00543814de71ff118776285c27
Created December 13, 2016 17:16
Command to generate gource visualization
# Install gource from compiling this http://gource.io/
# Install Prereqs like here http://stackoverflow.com/a/15105901/912450
# From here https://github.com/acaudwell/Gource/wiki/Videos#ffmpeg-using-x264-codec
./gource --fullscreen -1280x720 -o - --disable-auto-skip --seconds-per-day 0.1 --camera-mode overview --key -r 60 /<path-to-repo>/ | ../ffmpeg/ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 gource.mp4
@jperelli
jperelli / conditional_orderby.py
Last active January 26, 2024 11:56
Conditional order by in django's ORM
"""
Some table has two Date fields: expiredate and SALexpiredate
Both fields can be null
when SALexpiredate is not null, overrides expiredate
when ordering:
if SALexpiredate is not null, that field needs to be used
otherwise fallback to use expiredate
"""
from django.db.models import DateField, Case, When, F
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jperelli
jperelli / fortifix.sh
Created July 5, 2016 22:00
Fix forticlient linux route table to be able to coonect to internet from outside the VPN
#!/bin/sh
if [ "$(id -u)" != "0" ]; then
echo "You must run this script as root."
exit 1
fi
getaddr1 () {
hostname -I | tr " " "\n" | grep 192.168.100;
}
@jperelli
jperelli / README.md
Created September 8, 2015 11:51
Decorator to easily add permission requirements to a custom method in a viewset in django-rest-framework

Usage

class SomeViewSet(viewsets.ModelViewSet):
    queryset = models.Some.objects.all()
    serializer_class = SomeSerializer

    @detail_route(methods=['post'])
    @route_permissions('some_app.some_permission')
 def custom_method(self, request, pk=None):

This is a simple autoupdating angular directive to show sparklines in html. Changes on data will auto reflect in GUI.

Requires angularjs and highcharts or highstock.

Usage in html

<span hc-sparkline="data"></span>

in controller

@jperelli
jperelli / angular-sparkline.js
Created August 24, 2015 16:11
angular jquery sparkline directive
// modified from https://gist.github.com/pjsvis/6210002
// Requires jQuery from http://jquery.com/
// and jQuerySparklines from http://omnipotent.net/jquery.sparkline
// AngularJS directives for jquery sparkline
angular.module('sparkline', []);
angular.module('sparkline')
.directive('jqSparkline', [function () {