Skip to content

Instantly share code, notes, and snippets.

View toksdotdev's full-sized avatar

toks toksdotdev

View GitHub Profile
@alexweissman
alexweissman / BelongsToManyThrough.php
Last active May 12, 2023 07:58
Custom BelongsToManyThrough relationship for Laravel/Eloquent
<?php
/**
* UserFrosting (http://www.userfrosting.com)
*
* @link https://github.com/userfrosting/UserFrosting
* @copyright Copyright (c) 2013-2017 Alexander Weissman
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
namespace UserFrosting\Sprinkle\Core\Model\Relations;
@nikAizuddin
nikAizuddin / knuth_books.sh
Created May 23, 2017 03:36
UNIX Shell script to download four volumes of The Art of Computer Programming by Donald E. Knuth.
#!/bin/sh
################################################################################
## ##
## The Art of Computer Programming by Donald E. Knuth. ##
## ##
################################################################################
## Volume 1 - Fundamental Algorithms, 3rd Edition
/// Rust Fibonacci one-liner using `fold`
///
/// Not very practical: only for one time use,
/// since it will have to re-calculate all terms again and again
/// if used in a loop to create multiple items.
/// The use of `_` also suggests this is not an ideal solution.
fn main() {
let n = 10;
let x = (0..n).fold((0, 1), |x, _| (x.0+x.1, x.0)).0;
println!("{}: {}", n, x);
@DrPaulBrewer
DrPaulBrewer / UploaderForGoogleDrive.js
Last active December 17, 2022 09:49
Upload Browser Blobs to Files in Google Drive API v3
// upload.js, from https://github.com/googledrive/cors-upload-sample
// Contributors Steve Bazyl, Mike Procopio, Jeffrey Posnick, Renaud Sauvain
// License: Apache 2.0 http://www.apache.org/licenses/LICENSE-2.0
//
// Implements Resumable Upload for Google Drive as described by
// https://developers.google.com/drive/v3/web/resumable-upload
//
// Modified by Paul Brewer, Economic and Financial Technology Consulting LLC
// Nov. 1 2017
// 1. use Google Drive API V3 instead of V2
anonymous
anonymous / gods.rs
Created November 4, 2017 15:37
We create gods and men in rust.
extern crate rand;
use std::iter::Iterator;
use std::collections::HashMap;
use rand::{thread_rng, Rng};
macro_rules! s {
($x: expr) => {
$x.to_owned()
};
@nicholaskajoh
nicholaskajoh / tribonacci_triangle.py
Created November 6, 2017 09:09
Python function to generate n rows of a Tribonacci Triangle.
def tribonacci_triangle(n):
# n <- number of rows to generate
# a <- tribonacci triangle
a = [[1], [1, 1]]
if n == 1:
return [[1]]
elif n == 2:
return a
else:
# generate rows 3 to n
@jackdpeterson
jackdpeterson / dock.sh
Created April 4, 2018 18:05
Ubuntu 18.04 - Mixed DPI with 4k Laptop monitor (HiDPI), and two LoDPI monitors (27", 21")
#!/bin/bash
echo "setting frame buffer" &&
xrandr --fb 12800x2880 &&
echo "setting laptop monitor" &&
xrandr --output eDP-1-1 --mode 3840x2160 --rate 60 --primary&&
echo "setting 27 inch monitor" &&
xrandr --output DP-0.2 --mode 2560x1440 --scale-from 5120x2880 --panning 5120x2880+3840+0 --right-of eDP-1-1 &&
echo "setting the samsung monitor" &&
xrandr --output DP-0.1 --mode 1920x1080 --scale-from 3840x2160 --panning 3840x2160+8960+0 --right-of DP-0.2&&
echo "setting global scaling to 2x" &&
@fedme
fedme / install-virtualenv-ubuntu-zsh-wsl.md
Last active July 3, 2023 11:23
Install virtualenv on Ubuntu + ZSH (on WSL)

Virtualenv on WSL with ZSH

Install PIP

sudo apt install python-pip
sudo apt install python3-pip

pip --version
pip3 --version
@AGlass0fMilk
AGlass0fMilk / 99-tb16-dock.rules
Last active May 16, 2020 08:59
Mixed DPI on Ubuntu - Dell XPS 15 9570 and TB16 dock with 4K internal/1080p external displays
# put the following in a udev rule file
# for example /etc/udev/rules.d/99-tb16-dock.rule
ACTION=="add", SUBSYSTEM=="thunderbolt", ATTR{device_name}=="Dell Thunderbolt Dock", RUN+="/bin/systemctl --no-block start configure-tb16-dock.service"
@vladox
vladox / download_sentry_data.py
Last active April 13, 2024 01:00 — forked from bubenkoff/download_sentry_data.py
Download all sentry events for a project. Useful for data processing
"""Download sentry data.
usage:
python download_sentry_data.py <org>/<project> <api_key>
"""
import requests
import csv
import sys
if __name__ == '__main__':