Skip to content

Instantly share code, notes, and snippets.

View madewulf's full-sized avatar
🤷‍♂️
Multitasking.

Martin De Wulf madewulf

🤷‍♂️
Multitasking.
View GitHub Profile
@madewulf
madewulf / remove_perm.py
Created January 30, 2024 11:52
Remove permission to a set of users
from iaso.models import *
from django.contrib.auth.models import Permission
permission = Permission.objects.get(codename="iaso_completeness")
acc = Account.objects.get(id=20)
profiles = Profile.objects.filter(account=acc).filter(user__user_permissions=permission)
c = 0
print("permission", permission)
for profile in profiles:
print(profile)
s = new Set();
for (i = 0 ; i < 500000; i++)
s.add(""+i);
count = 0;
for (i = 0 ; i < 500000; i++)
if (s.has(""+i))
count = count + 1;
console.log(count);
@madewulf
madewulf / gist:6844cef0d23f0a895051472e71355102
Last active October 7, 2020 12:40
Set performance test (less than 10 seconds on my Mac)
from uuid import uuid4
s = set()
for i in range (500000):
s.add(str(uuid4()))
count = 0
for uu in s:
if uu in s:
count += 1
@madewulf
madewulf / Makefile
Created October 25, 2017 15:05 — forked from johan/Makefile
Makefile of the steps in Mike Bostock's command-line cartography tutorial, parts 1-4 https://medium.com/@mbostock/command-line-cartography-part-1-897aa8f8ca2c
# request one at http://api.census.gov/data/key_signup.html and paste it below
CENSUS_API_KEY=YOUR_CODE_HERE
# a factor 1609.34 squared
SQ_M_TO_SQ_MI=2589975.2356
#prereqs:
# npm install -g shapefile # 0.6.1
# npm install -g d3-geo-projection # 1.2.1
# npm install -g ndjson-cli # 0.3.0
@madewulf
madewulf / index.html
Created September 4, 2017 11:03
Britecharts minimal example
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/britecharts@2/dist/bundled/britecharts.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.10.2/d3.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/britecharts.min.css"/>
</head>
<body>
<h1>Britecharts test</h1>
<div class="js-bar-container"></div>
var rep = 20; // Number of repeat
var timeout = 370; // Delay between clicks
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function run() {
while (rep-- > 0) {$("#next_button").click(); await sleep(timeout);};
}
@madewulf
madewulf / salesforce.py
Created May 18, 2017 13:32
Python Flask and the Force.com REST API: Simple simple-salesforce example
from flask import Flask, redirect, request
import requests
from simple_salesforce import Salesforce
consumer_key = 'your_consumer_key'
consumer_secret = 'your_consumer_secret'
access_token_url = 'https://login.salesforce.com/services/oauth2/token'
redirect_uri = 'http://localhost:5000/callback'
authorize_url = 'https://login.salesforce.com/services/oauth2/authorize'
@madewulf
madewulf / TabComponent.swift
Created August 7, 2016 19:46 — forked from irace/TabComponent.swift
Easily roll your own `UITabBarController` alternatives. Here’s all the logic you need without assuming anything about your UI.
/**
* A class that can be part of a tabbed navigational interface (expected to be a `UIViewController` but can also be a
* coordinator that proxies through to an underlying controller).
*/
public protocol TabComponent {
/// The tab metadata
var tabItem: TabItem { get }
var viewController: UIViewController { get }
}
@madewulf
madewulf / link.md
Created July 25, 2016 12:45 — forked from Spaxe/link.md
@madewulf
madewulf / fbbot.py
Last active April 18, 2016 08:30
A POC Python echo bot over FB messenger API using Flask and Requests
from flask import Flask
from flask import request
import json
import requests
PAGE_ACCESS_TOKEN = ""
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def bot():