Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar

Adrian Statescu thinkphp

View GitHub Profile
@thinkphp
thinkphp / change-color-dir.txt
Created April 17, 2021 19:17
How do I change the color for directories with ls in console
;to change your directory colors, open up your ~/.bashrc file with your editor
;and make the following entry at the end of the
LS_COLORS=$LS_COLORS:'di=0;35:' ; export LS_COLORS
@thinkphp
thinkphp / repeatuntil.c
Last active December 12, 2020 08:11
repeat ... until control flow in c language
#include <stdio.h>
#define __repeat__ do
#define __until__(COND) while(!(COND))
int isPrime(int n) {
if( n == 0 || n == 1 ) return 0;
if( n == 2 || n == 3 ) return 1;
int i = 2,
def euclid_it a, b
while b != 0
r = a % b
a, b = b, r
end
a
end
def euclid_rec a, b
if b == 0
import sys
def _euclid(a,b):
if(b==0):
return a
else:
return _euclid(b,a%b)
def _euclid_it(a,b):
while(b):
r = a % b
#include <stdio.h>
#include <malloc.h>
#define FIN "ssm.in"
#define FOUT "ssm.out"
struct Arr {
int size;
int *data;
};
@thinkphp
thinkphp / euclid.rs
Last active November 4, 2020 18:04
Euclid's algortihm in Rust language.
use std::fs::File;
use std::io::{BufRead, BufReader, Write};
fn gcd(mut x: i32, mut y: i32) -> i32 {
assert!(x != 0 && y != 0);
while y != 0 {
let t = x % y;
alias lf="ls -l | egrep -v '^d'"
alias ldir='ls -d */'
alias ld="ls -l | egrep '^d'"
source .bash_profile
lancia@adonix.cs.unibuc.ro: $ld
lancia@adonix.cs.unibuc.ro: $lf
lancia@adonix.cs.unibuc.ro: $ pdftex filename.tex
lancia@adonix.cs.unibuc.ro: $ evince filename.pdf #open file PDF
let str = "adrianstatescu"
console.log(str)
let arr = [...str.toString()]
let finished = 0, swapped, size = arr.length;
while(!finished) {
/*
An Armstrong number is a number that is equal to the sum of digits raise to the power total number of digits in the number.
Some Armstrong numbers: 153, 370, 1634
*/
#include <stdio.h>
#define LL long long
int countDigits(int n) {
int count = 0;
@thinkphp
thinkphp / settheory.c
Created January 4, 2020 22:35
Set Theory
#include <stdio.h>
#define SIZE 1000
struct TSet {
unsigned int n;
int arr[SIZE];
};
typedef struct TSet Set;