Skip to content

Instantly share code, notes, and snippets.

@TiagoTi
TiagoTi / django.view.py
Created May 27, 2020 10:32
Django save InMemoryUploadedFile (a temporary uploaded file) to disk
from django.core.files.storage import default_storage
from django.core.files.base import ContentFile
file = request.FILES['your_file_fieldname']
path = default_storage.save('heart_of_the_swarm.txt', ContentFile(file.read()))
#https://twigstechtips.blogspot.com/2012/04/django-how-to-save-inmemoryuploadedfile.html
@TiagoTi
TiagoTi / .vimrc
Last active March 17, 2020 08:03
"Load Plugin Manager Pathogen
execute pathogen#infect()
"Disable compatible with vi to enable all features of vim
set nocompatible
"enable ç to enter in command mode
:map ç :
@TiagoTi
TiagoTi / gist:5a3232cadaa4b558ac4dbd5903f1d31a
Created March 17, 2020 07:21 — forked from romainl/gist:9970697
How to use Tim Pope's Pathogen

How to use Tim Pope’s Pathogen

I’ll assume you are on Linux or Mac OSX. For Windows, replace ~/.vim/ with $HOME\vimfiles\ and forward slashes with backward slashes.

The idea

Vim plugins can be single scripts or collections of specialized scripts that you are supposed to put in “standard” locations under your ~/.vim/ directory. Syntax scripts go into ~/.vim/syntax/, plugin scripts go into ~/.vim/plugin, documentation goes into ~/.vim/doc/ and so on. That design can lead to a messy config where it quickly becomes hard to manage your plugins.

This is not the place to explain the technicalities behind Pathogen but the basic concept is quite straightforward: each plugin lives in its own directory under ~/.vim/bundle/, where each directory simulates the standard structure of your ~/.vim/ directory.

# Colors
set -g default-terminal "xterm-256color"
set-option -g status-bg black
set-option -g status-fg white
set-option -g status-attr default
set -g pane-border-fg white
set -g pane-active-border-fg white
set -g pane-active-border-bg cyan
# No delay for escape key
var gulp = require('gulp');
var pug = require('gulp-pug');
gulp.task('default1', function() {
console.log('ola mundo');
});
gulp.task('where-do-we-go-now', function(){
console.log('https://github.com/gulpjs/gulp/tree/v3.9.1/docs/recipes');
@TiagoTi
TiagoTi / ping.js
Created June 6, 2018 09:47
pinging request
var request = require('request');
setInterval(function(){
request('http://www.google.com', function (error, response, body) {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
# redirect output and errors into file output.log:
nohup some_command > output.log 2>&1&
# abbreviated syntax for bash version >= ver.4:
nohup some_command &> output.log
#https://gist.github.com/umidjons/8417312
@TiagoTi
TiagoTi / SecurityConfig.java
Created May 30, 2018 16:22
basic atutentication
package br.net.ti2.MarinaAbramovick.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@TiagoTi
TiagoTi / screen cast to gif.ssh
Created February 3, 2017 11:28
How to create animated GIF images of a screencast?
sudo apt-get install imagemagick mplayer gtk-recordmydesktop
#Then use Desktop Recorder to capture a portion of the screen/application to use as the screencast.
mplayer -ao null <video file name> -vo jpeg:outdir=output
#Use ImageMagick to convert the screenshots into an animated gifs.
convert output/* output.gif
#you can optimize the screenshots this way:
convert output.gif -fuzz 10% -layers Optimize optimised.gif
require 'sinatra'
# Listen on all interfaces in the development environment
set :bind, '0.0.0.0'
get '/' do
"Hello World! Is it " + settings.bind + " you're looking for?"
end