Skip to content

Instantly share code, notes, and snippets.

View tahadostifam's full-sized avatar
🏠
Working from home

[ Taha. Dostifam‍ ] tahadostifam

🏠
Working from home
View GitHub Profile
@tahadostifam
tahadostifam / main.c
Created May 11, 2025 11:53
Concatenate strings in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *concatstr(const char *str1, const char *str2)
{
size_t len1 = strlen(str1);
size_t len2 = strlen(str2);
size_t total_length = len1 + len2;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
// Generic copy function for arrays of any data type
// Requires the size of each element to be provided
void internal_copy(void *source, size_t source_len, size_t elem_size,
void *destination, size_t dest_len,
size_t source_start_index, size_t dest_start_index,
@tahadostifam
tahadostifam / tut.md
Created January 30, 2025 10:11 — forked from rain1024/tut.md
Install pdflatex ubuntu

PdfLatex is a tool that converts Latex sources into PDF. This is specifically very important for researchers, as they use it to publish their findings. It could be installed very easily using Linux terminal, though this seems an annoying task on Windows. Installation commands are given below.

  • Install the TexLive base
sudo apt-get install texlive-latex-base
  • Also install the recommended and extra fonts to avoid running into the error [1], when trying to use pdflatex on latex files with more fonts.
@tahadostifam
tahadostifam / scope.rs
Created January 9, 2025 14:49
Scopes built in Rust
use std::{cell::RefCell, collections::HashMap, rc::Rc};
#[derive(Debug, Clone)]
pub struct Scope {
pub table: HashMap<String, Rc<RefCell<i32>>>,
pub parent: Option<Box<ScopeRef>>,
}
pub type ScopeRef = Rc<RefCell<Scope>>;
fn is_emoji(ch: char) -> bool {
(ch >= '\u{1F600}' && ch <= '\u{1F64F}') // Emoticons
|| (ch >= '\u{1F300}' && ch <= '\u{1F5FF}') // Miscellaneous Symbols and Pictographs
|| (ch >= '\u{1F680}' && ch <= '\u{1F6FF}') // Transport and Map Symbols
|| (ch >= '\u{1F700}' && ch <= '\u{1F77F}') // Alchemical Symbols
|| (ch >= '\u{1F780}' && ch <= '\u{1F7FF}') // Geometric Shapes Extended
|| (ch >= '\u{1F800}' && ch <= '\u{1F8FF}') // Supplemental Arrows-C
|| (ch >= '\u{1F900}' && ch <= '\u{1F9FF}') // Supplemental Symbols and Pictographs
|| (ch >= '\u{1FA00}' && ch <= '\u{1FA6F}') // Chess Symbols
@tahadostifam
tahadostifam / pointer-functions.c
Created December 7, 2024 14:35
pointer-functions in c
#include <stdio.h>
void do_something(char name[]) {
printf("Hi, %s\n", name);
}
int main()
{
void (*my_func)(char[]);
@tahadostifam
tahadostifam / is-number.rs
Last active October 25, 2024 11:14
Is the given input number? in Rust =/
fn is_number(src: String) -> bool {
let c: u32 = src.chars().nth(0).unwrap() as u32;
let bounds = ('1' as u32, '9' as u32);
return c >= bounds.0 && c <= bounds.1;
}
fn is_alpha(src: String) -> bool {
return src.to_lowercase() != src.to_uppercase();
}
@tahadostifam
tahadostifam / rails_turbo_redirect_to_magic.md
Created July 31, 2023 11:31
Rails Turbo Redirect To Magic

template.html.erb

<%= turbo_frame_tag dom_id(@model) do %>
  <%= render "form", model: @model %>
<% end %>

initializers/turbo_redirect.rb

module CustomTurboStreamActions