Skip to content

Instantly share code, notes, and snippets.

View mrf345's full-sized avatar

Mohamed Feddad mrf345

  • UAE
View GitHub Profile
@mausch
mausch / aws-workspaces.sh
Last active February 26, 2024 14:22
Run AWS WorkSpaces client on any Linux distro supporting Docker
#!/usr/bin/env bash
set -eu
dockerfile=$(mktemp)
trap "rm $dockerfile" EXIT
cat << EOF > $dockerfile
FROM ubuntu:bionic
RUN apt-get update && apt-get install -y wget gnupg2
@awerlang
awerlang / README
Last active February 22, 2024 01:24
A zypper wrapper that maximizes network throughput
zypper-download
===============
Downloads packages using any amount of available openSUSE mirrors.
Installation
------------
Copy both files to the following locations:
@HaiBV
HaiBV / addTwoHugeNumbers.js
Created November 7, 2019 18:15
addTwoHugeNumbers
// Singly-linked lists are already defined with this interface:
// function ListNode(x) {
// this.value = x;
// this.next = null;
// }
//
function addTwoHugeNumbers(a, b) {
var sum = null,
tmp,
carry = 0,
@schwarzeni
schwarzeni / util.go
Last active May 13, 2024 15:29
[golang] get specific network interface's IPv4 address
package util
import (
"errors"
"fmt"
"net"
)
// useful links:
// https://stackoverflow.com/questions/27410764/dial-with-a-specific-address-interface-golang
@sturmenta
sturmenta / firestore2json.js
Last active October 28, 2022 19:03
firestore to json & json to firestore
const admin = require('firebase-admin');
const fs = require('fs');
const serviceAccount = require('../../../../../../Private/myschool-data_transfer-key.json');
admin.initializeApp({ credential: admin.credential.cert(serviceAccount) });
const schema = require('./schema').schema;
const firestore2json = (db, schema, current) => {
@flaviocopes
flaviocopes / check-substring-starts-with.go
Last active April 16, 2023 03:02
Go: check if a string starts with a substring #golang
package main
import (
"strings"
)
func main() {
strings.HasPrefix("foobar", "foo") // true
}
(defun my-fancy-startup-screen (&rest args)
(clear-image-cache)
(let* ((pwidth (window-pixel-width))
(pheight (* pwidth 0.75))
(file (expand-file-name "~/some-background.jpg"))
(tfile "/tmp/emacs-splash.jpg")
(color "white")
(font "/usr/share/fonts/corefonts/times.ttf")
(rt (/ pwidth 1000.0))
(size1 (* 80.0 rt)) (size2 (* 16.0 rt)) (size3 (* 24.0 rt))
@peterhurford
peterhurford / pytest-fixture-modularization.md
Created July 28, 2016 15:48
How to modularize your py.test fixtures

Using py.test is great and the support for test fixtures is pretty awesome. However, in order to share your fixtures across your entire module, py.test suggests you define all your fixtures within one single conftest.py file. This is impractical if you have a large quantity of fixtures -- for better organization and readibility, you would much rather define your fixtures across multiple, well-named files. But how do you do that? ...No one on the internet seemed to know.

Turns out, however, you can define fixtures in individual files like this:

tests/fixtures/add.py

import pytest

@pytest.fixture
@eszterkv
eszterkv / randomchoice.js
Created July 14, 2016 12:16
A JavaScript solution for random choice from an array.
function randomChoice(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}