Skip to content

Instantly share code, notes, and snippets.

@yassinagx
yassinagx / messagepack_client.js
Created June 3, 2023 15:56 — forked from faisal00813/messagepack_client.js
Client for sending the packed messagepack data to web server
const request = require('request')
const msgpack = require("msgpack-lite");
var packedData = msgpack.encode({
"str" : "Something",
"number" : 4.0,
"arr": ["one","two"],
"nClass": {
"doubleNumber" : 35.0,
"nums" : [34,23]

Rails & Trix: Add Underline, Superscript, and Subscript

This guide will walk you through adding some extra features such as the ability to underline your text, or enhance your content by adding superscripts or subscripts for annotations or Math equations.

Prerequisites: Instruction guide assumes that you have created a Rails application and installed ActionText.

What will you learn:

@yassinagx
yassinagx / flac-to-mp3.sh
Created March 4, 2022 13:09 — forked from ksu006/flac-to-mp3.sh
Script to convert .flac audio files into 320kbps .mp3 files (need flac and lame installed)
#!/bin/sh
for file in *.flac; do flac -cd "$file" | lame -h -b 320 - "${file%.flac}.mp3"; done
@yassinagx
yassinagx / conditional_chaining_with_tap.rb
Created February 2, 2022 14:29 — forked from abachman/conditional_chaining_with_tap.rb
Conditional query chaining in Rails 3
# I want a list of 6 non-administrators who are not the
# current user only if someone is logged in. Otherwise,
# don't check current_user's id.
# instead of this:
if user_signed_in?
@other_users = User.non_admin.limit(6).where("name IS NOT NULL")
else
@other_users = User.non_admin.limit(6).where(['id != ?', @user.id]).where("name IS NOT NULL")
@yassinagx
yassinagx / index.md
Created October 19, 2017 19:07 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one