This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace function epoch_to_jd(float) RETURNS int as $$ | |
BEGIN | |
return ($1 / (24*3600) + 2440588)::int; | |
END; | |
$$ LANGUAGE plpgsql; | |
create or replace function timestamp_to_jd(timestamp with time zone) RETURNS int as $$ | |
BEGIN | |
return epoch_to_jd(extract (epoch from $1)); | |
END; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const cluster = require('cluster'); | |
const mysql = require('mysql'); | |
const numCPUs = require('os').cpus().length; | |
const app = express(); | |
const PORT = 3000; | |
const pool = mysql.createPool({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def retry(exceptions, max_tries=5, delay=1): | |
def decorator(function): | |
def wrapper(*args, **kwargs): | |
attempt = 0 | |
while attempt < max_tries: | |
try: | |
return function(*args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
website="$1" | |
certificate_file=$(mktemp) | |
echo -n | openssl s_client -servername "$website" -connect "$website":443 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > $certificate_file | |
date=$(openssl x509 -in $certificate_file -enddate -noout | sed "s/.*=\(.*\)/\1/") | |
date_s=$(date -d "${date}" +%s) | |
now_s=$(date -d now +%s) | |
date_diff=$(( (date_s - now_s) / 86400 )) | |
echo "$website will expire in $date_diff days" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source_path='/path/to/booklet' | |
target_path='/path/to/result' | |
dpi=200 | |
quality=25 | |
max_size=1536 # in kb | |
pdf2pic() { | |
dirname="${i%.*}" | |
mkdir -p "$dirname" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1. Select items by the value of a first level attribute (#1 way) | |
SELECT * FROM users WHERE metadata @> '{"country": "Peru"}'; | |
-- 2. Select items by the value of a first level attribute (#2 way) | |
SELECT * FROM users WHERE metadata->>'country' = 'Peru'; | |
-- 3. 3. Select item attribute value | |
SELECT metadata->>'country' FROM users; | |
-- 4. Select only items where a particular attribute is present |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION g2j(in_date timestamp with time zone) | |
RETURNS character varying AS | |
$BODY$ | |
DECLARE | |
aday smallint; | |
amonth smallint; | |
ayear smallint; | |
a1 char(4); | |
b1 char(2); | |
c1 char(2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import requests | |
from bs4 import BeautifulSoup | |
url = 'https://www.digikala.com/search/category-tablet/?has_selling_stock=1&type[0]=211&attribute[A20378][0]=25460&attribute[A20378][1]=25462&attribute[A20421][0]=25676&attribute[A20421][1]=25677&pageno=1&last_filter=type&last_value=211&sortby=4' | |
word = 'قلم' | |
first_char = '?' | |
if first_char in url: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.util.List; | |
import java.util.ArrayList; | |
import java.util.concurrent.TimeUnit; | |
import java.util.Collections; | |
import java.util.Scanner; | |
public class randomEmail { | |
public static void main(String[] args) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class madihi { | |
public static void main(String[] args) { | |
Scanner scan = new Scanner(System.in); | |
System.out.print("enter n = "); | |
int n = scan.nextInt(); | |
int[] a = new int[n+1]; | |
int sum1 = 0; | |
for(int i = 1 ; i < n ; i++){ | |
System.out.print("enter number " + i + " = "); |