Skip to content

Instantly share code, notes, and snippets.

View userr2232's full-sized avatar
🌴
On vacation

Reynaldo RZ userr2232

🌴
On vacation
  • Vancouver, Canada
View GitHub Profile
@userr2232
userr2232 / multiprocess_selenium.py
Created December 24, 2023 00:34 — forked from wooddar/multiprocess_selenium.py
Easy Python script to run selenium web workers/browsers in parallel
"""
This is an adaptable example script for using selenium across multiple webbrowsers simultaneously. This makes use of
two queues - one to store idle webworkers and another to store data to pass to any idle webworkers in a selenium function
"""
from multiprocessing import Queue, cpu_count
from threading import Thread
from selenium import webdriver
from time import sleep
from numpy.random import randint
@userr2232
userr2232 / OneDriveError.cs
Created March 9, 2023 06:18
OneDrive Error Code Handling
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Microsoft.OneDrive
{
public class OneDriveError
#include <iostream>
#include <string>
#include <plasma/common.h>
std::string hex2bin(const std::string& h) {
uint8_t b[plasma::kUniqueIDSize] = {};
for(size_t i = 0; i < plasma::kUniqueIDSize; ++i)
b[i] = static_cast<uint8_t>(std::stoul(std::string({h[2*i], h[2*i+1]}), nullptr, 16));
return std::string(reinterpret_cast<const char *>(b), plasma::kUniqueIDSize);
}
@userr2232
userr2232 / build.sh
Created July 10, 2021 06:15 — forked from lucasea777/build.sh
Python C Extension Hello World
gcc -fpic --shared $(python3-config --includes) greetmodule.c -o greet.abi3.so
# can also use $(pkg-config --cflags python-3.5)
# or
# python3 setup.py install --record files.txt --user
@userr2232
userr2232 / brats_challenge_starterkit.py
Created October 18, 2020 21:39 — forked from faustomilletari/brats_challenge_starterkit.py
BraTS 2020 challenge Eisen starter kit
"""
Eisen BraTS2020 challenge starter kit
NOTE: you need to register to the challenge, download and unpack the data in
order to be able to run the following example.
Find more info here: https://www.med.upenn.edu/cbica/brats2020/data.html
Information about Eisen can be found at http://eisen.ai -- Join the community on Slack https://bit.ly/2L7i6OL
from csv import reader
from cassandra.cluster import Cluster, BatchStatement
from time import time
cluster = Cluster(['10.0.2.6', '10.0.2.7']);
session = cluster.connect('p3');
query = """
INSERT INTO ratings (userId, movieId, rating, timestamp)
VALUES (?, ?, ?, ?)
const fib = (x) => {
if(x === 0) return 0;
if(x === 1) return 1;
return fib(x-1) + fib(x-2);
};
@userr2232
userr2232 / references.php
Created February 12, 2019 19:35
PHP references example
<?php
class A{
public $foo = 1;
}
$a = new A;
// here we just copy the object id to $b
$b = $a;
$a->foo = 2;
@userr2232
userr2232 / objects.php
Created February 12, 2019 19:01
PHP objects id example
<?php
class A {}
$a = new A;
$b = $a;
// spl_object_hash($object) returns a unique identifier for the object
if (spl_object_hash($a) === spl_object_hash($b)) {
echo "Object variables store a copy of a unique object identifier!".PHP_EOL;
echo "This unique id in this example is ".spl_object_hash($a);

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)