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
#!/usr/bin/env instantfpc
uses
sysutils;
var
entrada: String;
begin
/*
License: GNU GPLv2
Authors: Julián Perelli
Organization: Sistemas Operativos Avanzados 2015 - UTN FRLP
Compile with: gcc primos.c -o primos
Run with: ./primos
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
/*
License: GNU GPLv2
Authors: Julián Perelli
with ideas from http://people.sc.fsu.edu/~jburkardt/c_src/mpi/mpi.html
Organization: Sistemas Operativos Avanzados 2015 - UTN FRLP
Compile with: mpicc primos_mpi.c -o primos_mpi
Run with: mpirun -n 4 ./primos_mpi 100
*/
#include "mpi.h"
@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 () {

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 / 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):
@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;
}
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 / 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