Skip to content

Instantly share code, notes, and snippets.

@diogosimao
diogosimao / vpn-setup.sh
Created November 17, 2022 19:25 — forked from bsless/vpn-setup.sh
Set up a bunch of OpenVPN connections using nmcli with username and password
#!/usr/bin/env bash
USERNAME="$1"
PASS="$2"
for f in *.ovpn
do
name=`basename -s .ovpn $f`;
nmcli connection import type openvpn file $f
nmcli connection modify "${name}" +vpn.data connection-type=password-tls
@diogosimao
diogosimao / mongo_to_csv.py
Created January 17, 2022 19:56 — forked from mieitza/mongo_to_csv.py
python mongo to csv use pandas.
# @Author: xiewenqian <int>
# @Date: 2016-11-28T20:35:09+08:00
# @Email: wixb50@gmail.com
# @Last modified by: int
# @Last modified time: 2016-12-01T19:32:48+08:00
import pandas as pd
from pymongo import MongoClient
@diogosimao
diogosimao / gist:2ec01c6e9767678035d9ba56c94d7baa
Created November 25, 2021 18:44 — forked from codeboy/gist:923f74b72abda9502f42
A very simple example of python code to us with python-libtorrent
'''
You should try libtorrent (rasterbar). http://libtorrent.org
If you want to write your client in python, on linux, install it with:
sudo apt-get install python-libtorrent
A very simple example of python code to use it to download a torrent:
'''
import libtorrent as lt
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@diogosimao
diogosimao / appsScript_ListFilesFolders_ver.2.js
Created August 13, 2019 12:01 — forked from mesgarpour/appsScript_ListFilesFolders_ver.2.js
[Google Apps Script] List all files & folders in a Google Drive folder, & write into a speadsheet
/*
* Copyright 2017 Mohsen Mesgarpour
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@diogosimao
diogosimao / intercooler.html
Created March 31, 2019 18:19 — forked from andybak/intercooler.html
Example of adding Django CSRF token in an page that POSTs using intercooler.
{% extends "custom_base.html" %}
{% block content %}
<form id="defaults" >
<input name="csrfmiddlewaretoken" type="hidden" value="{{ csrf_token }}">
</form>
<table>
{% for row in items %}
@diogosimao
diogosimao / through_relationships.py
Created October 30, 2018 01:28 — forked from jhgaylor/through_relationships.py
Example of using a through model in Django and filtering by a value on the custom through model.
class A(models.Model):
things = models.ManyToManyField("B", through=ThroughModel)
class B(models.Model):
text = models.TextField()
class ThroughModel(models.Model):
a = models.ForeignKey(A)
b = models.ForeignKey(B)
extra = models.BooleanField()
@diogosimao
diogosimao / fields.py
Created October 4, 2018 02:28 — forked from dokterbob/fields.py
Email field with domain existence validation for Django.
import logging
logger = logging.getLogger(__name__)
# Note: we need dnspython for this to work
# Install with `pip install dnspython`
import dns.resolver, dns.exception
from django import forms
from django.utils.translation import ugettext as _
@diogosimao
diogosimao / part.md
Created August 23, 2018 18:23 — forked from oisobstudio/part.md
Django Pagination Server-Side Menggunakan DataTable

myapp/views.py

import json

from django.views.generic import View
from django.http import HttpResponse
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.db.models import Q
from django.core.serializers.json import DjangoJSONEncoder
@diogosimao
diogosimao / firefox-developer-edition.md
Last active June 11, 2018 12:50 — forked from mahammad/firefox-developer-edition.md
How To Install Firefox Developer Edition and create desktop icon

Download

Source to download: link

Install

chose other install way

1. Open Terminal Ctrl+Alt+T Download Firefox Developer Edition tar file