Skip to content

Instantly share code, notes, and snippets.

Avatar

Petr im7mortal

View GitHub Profile
@im7mortal
im7mortal / install_gpu_docker.sh
Created Jul 21, 2017
Install docker and nvidia-docker
View install_gpu_docker.sh
sudo apt-get update
sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb
sudo apt-get install nvidia-modprobe
View slack_delete.py
import requests
import time
import json
token = ''
#Delete files older than this:
ts_to = int(time.time()) - 30 * 24 * 60 * 60
def list_files():
View get uploaded file information
$(':file').change(function(){
var file = this.files[0];
var name = file.name;
var size = file.size;
var type = file.type;
console.log(name, size, type, file);
var myVideoPlayer = document.createElement('video');
myVideoPlayer.src = URL.createObjectURL(file);
myVideoPlayer.addEventListener('loadedmetadata', function() {
console.log(myVideoPlayer.duration);
View gist:67584280fb16814af2a1
package main
import (
"log"
"net/http"
"os"
"database/sql"
_ "github.com/lib/pq"
"fmt"
"encoding/json"
@im7mortal
im7mortal / http_get.go
Created Sep 25, 2015 — forked from ijt/http_get.go
Example of using http.Get in go (golang)
View http_get.go
package main
import (
"fmt"
"http"
"io/ioutil"
"os"
)
func main() {
View bash alias
alias lol='(cd /home/peter/tools/WebStorm-141.1550/bin/ && ./webstorm.sh &) && (cd /home/peter/tools/smartgit/bin/ && ./smartgit.sh &) && fg'
View gist:a39b1344436e47f29adc
#!/bin/bash
SAVEIFS=$IFS
#вырезаю первые 47 секунд https://blog.dbrgn.ch/2013/1/29/cut-video-from-bash-with-ffmpeg/
# IFS это сепаратор http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
IFS=$(echo -en "\n\b")
for f in *
do
NAME=${f%\ Salman*} # separator \ Salman*
ffmpeg -ss 00:00:47.0 -i $f -acodec copy -vcodec copy -async 1 $NAME.mp4
rm $f
View gist:d561f03316edf31de358
phoneHome = '+7(43243)2-34-43'.split('');
var num, num1, flag ;
for(var i = 0; i < phoneHome.length + 1; i++) {
console.log(phoneHome.length );
if(i === 7) {
flag = true;
num = phoneHome[i];
phoneHome[i] = ')';
continue;
}
View gist:a2c869fce8475a23f84f
function mixer(arr){
for ( var i = arr.length; i-->0; ) {
var t = arr[i],
j = Math.floor(i*Math.random());
arr[i] = arr[j];
arr[j] = t;
}
return arr;
}