Skip to content

Instantly share code, notes, and snippets.

View arashm's full-sized avatar
:shipit:

Arash Mousavi arashm

:shipit:
View GitHub Profile
@ityonemo
ityonemo / test.md
Last active April 25, 2024 10:23
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@andrebrait
andrebrait / keychron_linux.md
Last active April 25, 2024 13:24
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Note: many newer Keychron keyboards use QMK as firmware and most tips here do not apply to them. Maybe the ones related to Bluetooth can be useful, but everything related to Apple's keyboard module (hid_apple) on Linux, won't work. As far as I know, all QMK-based boards use the hid_generic module instead. Examples of QMK-based boards are: Q, Q-Pro, V, K-Pro, etc.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work (NOT FOR QMK-BASED BOARDS)

Older Keychron keyboards (those not based on QMK) use the hid_apple driver on Linux, even in the Windows/Android mode, both in Bluetooth and Wired modes.

@lu4nm3
lu4nm3 / main.rs
Last active January 16, 2024 09:38
Tokio Async: Concurrent vs Parallel
use futures::StreamExt;
use std::error::Error;
use tokio;
use tokio::macros::support::Pin;
use tokio::prelude::*;
use tokio::time::{Duration, Instant};
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut multi_threaded_runtime = tokio::runtime::Builder::new()
.threaded_scheduler()
// Code from: http://patshaughnessy.net/2020/1/20/downloading-100000-files-using-async-rust
//
// Cargo.toml:
// [dependencies]
// tokio = { version = "0.2", features = ["full"] }
// reqwest = { version = "0.10", features = ["json"] }
// futures = "0.3"
use std::io::prelude::*;
use std::fs::File;
@jnewman12
jnewman12 / Forms.md
Last active November 3, 2023 15:36
Forms, form_for, link_to lesson

Forms, form_for, and link_to


Lesson Objectives

  1. Understand forms and the ways we write them
  2. Understand the difference between form_tag and form_for
  3. Understand link_to and how we can use it to dynamically link our application together
@danielgtaylor
danielgtaylor / gist:0b60c2ed1f069f118562
Last active April 2, 2024 20:18
Moving to ES6 from CoffeeScript

Moving to ES6 from CoffeeScript

I fell in love with CoffeeScript a couple of years ago. Javascript has always seemed something of an interesting curiosity to me and I was happy to see the meteoric rise of Node.js, but coming from a background of Python I really preferred a cleaner syntax.

In any fast moving community it is inevitable that things will change, and so today we see a big shift toward ES6, the new version of Javascript. It incorporates a handful of the nicer features from CoffeeScript and is usable today through tools like Babel. Here are some of my thoughts and issues on moving away from CoffeeScript in favor of ES6.

While reading I suggest keeping open a tab to Babel's learning ES6 page. The examples there are great.

Punctuation

Holy punctuation, Batman! Say goodbye to your whitespace and hello to parenthesis, curly braces, and semicolons again. Even with the advanced ES6 syntax you'll find yourself writing a lot more punctuatio

@carols10cents
carols10cents / ruby-to-rust-cheat-sheet.md
Last active November 24, 2020 23:12
Ruby to Rust Cheat Sheet

Ruby to Rust Cheat Sheet

The goal of this is to have an easily-scannable reference for the most common syntax idioms in Ruby and Rust so that programmers most comfortable with Ruby can quickly get through the syntax differences and feel like they could read and write basic Rust programs.

What do you think? Does this meet its goal? If not, why not?

Variables

Ruby:

@martianboy
martianboy / generators.js
Last active August 29, 2015 14:04
Testing higher-order functions with es6 generators
/* This will run async without creating intermediate arrays. */
function* makeGeneratorFromArray(array){
var nextIndex = 0;
while(nextIndex < array.length) {
yield array[nextIndex++];
}
}
@JunichiIto
JunichiIto / alias_matchers.md
Last active April 16, 2024 16:18
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value