Skip to content

Instantly share code, notes, and snippets.

View srezasm's full-sized avatar

SReza SMohseni srezasm

View GitHub Profile
@srezasm
srezasm / gist:924beeafa572e6af80636b16fda27220
Created January 15, 2023 11:26
Remove white space from all files in a directory and and sub-directories python script
from os import listdir, rename
from os.path import isfile, isdir, join, basename
def scroll_dir(dpath: str):
children = [c for c in listdir(dpath)]
for c in children:
p = join(dpath, c)
if isdir(p):
scroll_dir(p)
@srezasm
srezasm / moveFilesIntoBaseDir.py
Created January 2, 2023 16:34
move files into base directory python script
from os import listdir, rename
from os.path import isfile, isdir, join
def scroll_dir(dpath):
children = [c for c in listdir(dpath)]
for c in children:
p = join(dpath, c)
if isdir(p):
scroll_dir(p)
@srezasm
srezasm / Determinant.cpp
Created December 30, 2022 15:15
Determinant algorithm in c++
#include <math.h>
#include <stdio.h>
#include <iostream>
int Determinant(int**, int);
void PrintMatrix(int**, int, int);
int** ReadMatrix(int, int);
int main(int argc, char const* argv[]) {
int n;
#include <iostream>
using namespace std;
void CinArray(int arr[], int n) {
cout << "enter " << n << " numbers: ";
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
}
@srezasm
srezasm / IRIS_ML.py
Last active August 25, 2022 07:19
IRIS Dataset ML Example With SGD-Regressor
from sklearn.datasets import load_iris
import matplotlib.pyplot as plt
import numpy as np
from sklearn.linear_model import SGDRegressor
# initiate main params
iris = load_iris()
x = iris.data
y = iris.target
@srezasm
srezasm / get_list_members.py
Created April 15, 2022 18:15
How to get twitter list members with tweepy
import tweepy
auth = tweepy.OAuthHandler("CONSUMER_KEY", "CONSUMER_SECRET")
auth.set_access_token("ACCESS_TOKEN","ACCESS_TOKEN_SECRET")
api = tweepy.API(auth)
list_id = 1476313231572578313 # your list id
for user in tweepy.Cursor(api.list_members, list_id=list_id).items():
# hack 'm all
@srezasm
srezasm / App.jsx
Last active September 13, 2020 10:28
lazyLoadingRoutes After
import React from "react";
import { BrowserRouter, Route, Link, Switch } from "react-router-dom";
const AskPage = React.lazy(() => import("./AskPage"));
const App = () => {
return (
<BrowserRouter>
<Link to="/ask">AskPage</Link>
<Route exact path="/ask">
@srezasm
srezasm / App.js
Last active September 13, 2020 10:28
lazyLoadingRoutes B4
import React from "react";
import { BrowserRouter, Route, Link, Switch } from "react-router-dom";
import AskPage from "./AskPage";
const App = () => {
return (
<BrowserRouter>
<Link to="/ask">AskPage</Link>
<Route exact path="/ask" component={AskPage} />
@srezasm
srezasm / truncate an array.js
Created September 6, 2020 13:36
truncate an array
let array = [0, 1, 2, 3, 4, 5];
array.length = 3;
console.log(array);
// Result: [0, 1, 2]
@srezasm
srezasm / remove last digits.js
Created September 6, 2020 13:35
remove last digits
const int = 1553 / 10 | 0;
console.log(int);
// Result: 155
console.log(
typeof int
)
// Result: number