Skip to content

Instantly share code, notes, and snippets.

View Clivern's full-sized avatar

Ahmed Clivern

View GitHub Profile
Python 3.9.7 (default, Oct 12 2021, 22:38:23)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> x = [1, 2, 3, 4, 5]
>>> x.append(6)
>>> x
[1, 2, 3, 4, 5, 6]
>>> x.index(6)
5
@Clivern
Clivern / Dockerfile
Created November 2, 2021 19:43
Run a Python Script with Docker Container
FROM python:3.9.7
MAINTAINER Clivern
RUN mkdir -p /etc/muffin
VOLUME /etc/muffin
CMD ["python"]
@Clivern
Clivern / RAILS_CHEATSHEET.md
Created October 23, 2021 10:40 — forked from mdang/RAILS_CHEATSHEET.md
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet

Architecture

Create a new application

Install the Rails gem if you haven't done so before

@Clivern
Clivern / jq-cheetsheet.md
Created October 20, 2021 09:48 — forked from olih/jq-cheetsheet.md
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@Clivern
Clivern / github_emoji.md
Created September 8, 2021 17:14
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue:
@Clivern
Clivern / connection_pool.go
Created September 3, 2021 21:51
Singleton Pattern Connection Pool
package main
import (
"fmt"
"sync"
)
// DB type
type DB struct{}
@Clivern
Clivern / generics.rs
Created August 16, 2021 21:48
Rust Generics
fn sum<T: std::ops::Add<Output = T>>(n1: T, n2: T) -> T {
n1 + n2
}
fn max<T: std::cmp::PartialOrd>(n1: T, n2: T) -> T {
if n1 > n2 { n1 } else { n2 }
}
fn main() {
println!("{}", sum(2, 3));
@Clivern
Clivern / core.rs
Created August 15, 2021 17:45
Rust Pass by Value and Reference
// Pass by refernce
fn double1(x: &mut [i32; 10]) {
for i in 0..10 {
x[i] += 2;
}
}
// Pass by value
fn double2(x: [i32; 10]) -> [i32; 10] {
@Clivern
Clivern / rust_struct.rs
Created August 13, 2021 20:13
Rust Structs
struct Student {
Name: String,
Age: i16,
}
struct Stud(String, i16);
const JKO: i32 = 3;
enum VehicleType {
@Clivern
Clivern / circuit_breaker.go
Created July 25, 2021 18:26
Circuit Breaker Pattern in golang
// Copyright 2021 Clivern. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package main
import (
"errors"
"fmt"
"sync"