Skip to content

Instantly share code, notes, and snippets.

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

Meysam Shirdel mshirdel

🏠
Working from home
View GitHub Profile
@mshirdel
mshirdel / docker-multi-stage
Created June 7, 2023 11:04
DockerMultiStage
# syntax=docker/dockerfile:1
FROM golang:1.20 AS build-stage
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
@mshirdel
mshirdel / clean_gitignore_cache
Created January 27, 2019 08:10
Fix gitignore problem
git rm -r --cached .
git add .
git commit -m "fixed untracked files"
@mshirdel
mshirdel / prime.rb
Created April 19, 2018 09:55
prime number up to 1M
def is_prime(num)
(2..(num ** 0.5).to_i).each { |n| return false if num % n == 0 }
true
end
number_of_primes = 0
(2..1000000).each { |n| number_of_primes += 1 if is_prime n }
puts number_of_primes
#!/bin/bash
aria2c -j1 -i list -c --save-session output.log
has_error=`wc -l < output.log`
while [ $has_error -gt 0 ]
do
echo "still has $has_error errors, rerun aria2 to download ..."
aria2c -j1 -i list -c --save-session output.log
has_error=`wc -l < output.log`
sleep 10
@mshirdel
mshirdel / MongoDB-in-query
Created September 17, 2017 05:20
Use the $in Operator to Match Values
db.getCollection('bss_robot_reports').find({"ActionName": "Calling Shahkar Web Service Result", "OrderId": {$in : [380930,300254,205874]} }).sort({ReportDate: -1})
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
@mshirdel
mshirdel / InsertActionEF-CodeFirst.cs
Created April 18, 2017 10:29
Insert Action in EF Code First
public override void Up()
{
var actions = new Dictionary<string, string>() {
{ "ActionName", "توضیح" }
};
using (CRMEntities db = new CRMEntities())
{
foreach (var item in actions)
{
var actionItem = db.Actions.FirstOrDefault(a => a.ActionName == item.Key);
@mshirdel
mshirdel / find_content_file
Created October 10, 2016 07:31
Find in file content
grep -rnw '/path/to/somewhere/' -e "pattern"
@mshirdel
mshirdel / MakeCSProperty.rb
Last active September 21, 2016 11:11
Convert underscored text to C# property
ARGV.each do |arg|
text=File.open(arg).read
text.gsub!(/\r\n?/, "\n")
text.each_line do |line|
p = line.gsub("\n",'').split('_').collect(&:capitalize).join
puts "public string #{p} { get; set; } // #{line}"
end
end