Skip to content

Instantly share code, notes, and snippets.

View davidonet's full-sized avatar

David Olivari davidonet

  • David O Net
  • Fozières, France
View GitHub Profile
@davidonet
davidonet / bakeall.py
Last active August 7, 2020 16:50
Scaleway archlinux blender 2.82
import bpy
def enable_gpus(device_type, use_cpus=False):
preferences = bpy.context.preferences
cycles_preferences = preferences.addons["cycles"].preferences
cuda_devices, opencl_devices = cycles_preferences.get_devices()
if device_type == "CUDA":
devices = cuda_devices
elif device_type == "OPENCL":
@davidonet
davidonet / tem_next.json
Last active August 31, 2018 04:20
Next event
{
"next":"Samedi 15 Septembre, 11h à Saint-Brès et 15h à Grabels"
}
@davidonet
davidonet / logload.sh
Created December 21, 2016 09:26
Log cpuload and memory usage to graylog2 server using udp
#!/bin/bash
load=`cat /proc/loadavg | awk '{print $1}'`
mem=`free -o | awk 'NR==2{print $3}'`
echo '{"version": "1.1","host":"'$HOSTNAME'","short_message":"cpumem","level":4,"_load":'$load',"_mem":'$mem'}' | nc -c -w1 -u graylog.server 12201
@davidonet
davidonet / gist:8d8461db8a0b6720c9f1
Last active November 5, 2015 05:30
Gelf IP logging
IP=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
MSG=\{\"short_message\":\"heartbeat\",\"host\":\"host\",\"address\":\"$IP\"\}
curl -XPOST http://gelf.logging.com/gelf -p0 -d $MSG
@davidonet
davidonet / ip2gelf.sh
Created January 17, 2014 16:33
sending ip to Graylog2
#!/bin/sh
IP=`ip -f inet -o address show enp1s0f0 | awk '{print $4}'`
echo '{"version": "1.1","host":"'$HOSTNAME'","short_message":"ip","level":4,"_ip":"'$IP'"}' | nc -w 1 -u <server_address> 12201
@davidonet
davidonet / agent
Last active February 15, 2018 05:22
Using ElectricImp to pilot LPD8806 ledstrip from a webpage
function requestHandler(request, response) {
try {
if ("color" in request.query) {
local ledState = request.query.color.tointeger();
local sleep=10;
if ("sleep" in request.query){
sleep = request.query.sleep.tointeger();
}
params<-{"color":ledState,"sleepTime":sleep};
@davidonet
davidonet / gist:3552420
Created August 31, 2012 13:03
reduce PDF file size from command line
#from http://www.ubuntugeek.com/ubuntu-tiphowto-reduce-adobe-acrobat-file-size-from-command-line.html
$ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
@davidonet
davidonet / gist:2875268
Created June 5, 2012 14:15
Processing jar signing
http://www.akeric.com/blog/?p=1352
$ ant build
$ jarsigner -verbose -keystore ~/my-release-key.keystore `pwd`/bin/MucemApp-release-unsigned.apk davidonet
@davidonet
davidonet / gist:2349467
Created April 10, 2012 08:51
FullScreen Hack Android
try {
Process proc = Runtime.getRuntime().exec(new String[] {
"su", "-c", "service call activity 79 s16 com.android.systemui"
}
);
try
{
proc.waitFor();
}
@davidonet
davidonet / gist:2300373
Created April 4, 2012 11:03
stop/remove/disable the system bar (need to be su before issuing this command)
http://stackoverflow.com/questions/5109988/is-there-a-way-to-hide-the-system-bar-in-android-3-0-its-an-internal-device-an
To stop/remove/disable the system bar (need to be su before issuing this command):
$ service call activity 79 s16 com.android.systemui
To restore the system bar just simply issue this command:
$ am startservice -n com.android.systemui/.SystemUIService