Skip to content

Instantly share code, notes, and snippets.

@sibil
sibil / print_if_dir_exists_bash.sh
Created May 24, 2022 16:51
bash script to check if directories(1 to 100) exist
for (( i = 1; i < 100; i++ ))
do
[ -d $i ] || echo $i
done
#This is a list with three names.
numbers = [10, 20, 50]
result = 0
for number in numbers:
result = result + number
print("Result " + str(result) + " number:" + str(number))
print("Sum is:" + str(result))
# Dictionaries are made of key-value pairs
# In the example below, names are the keys and values are their ages.
students = {'bilal' : 15, 'ibraheem' : 19, 'luqman' : 15}
print(students)
#add a new key/value pair to the Dictionary
students['imad'] = 18
@sibil
sibil / d8.sh
Created June 17, 2021 11:49
Set appropriate permission for Drupal 8
#assuming centos user and apache
#in ubuntu, please use ubuntu:www-data
#chown -R ubuntu:www-data .
chown -R centos:apache .
find . -type d -exec chmod u=rwx,g=rx,o= '{}' \;
find . -type f -exec chmod u=rw,g=r,o= '{}' \;
#Ensure that the sites directory is proper
cd web/sites/
@sibil
sibil / gist:9aa328937f663b376cefc37b244dac38
Created June 1, 2021 03:56
Home work - string slicing
def getFirstNameFromFullName(full_name):
# write the code to get the first name
# and assign it to the variable first_name
return first_name
name = "Abdullah Al Rajeh"
print("First name is : "+ getFirstNameFromFullName(name) )
@sibil
sibil / version.py
Created December 3, 2020 11:42 — forked from fdns/version.py
Version extraction for OpenedX
#!/usr/bin/env python3
# Run me with sudo ./version.py > result
import csv
import sys
import os
import re
class VersionAnalyzer:
def __init__(self):
self.out = csv.writer(sys.stdout)
@sibil
sibil / sendSMS
Last active October 2, 2020 15:13
if userVerified(user):
sendSMS(user.mobile, "1234")
showOTPPage()
def sendSMS(recipient, message):
        message = "OTP: " + str(message)
        task = {"message": message, "number": recipient, "password": SMS_VENDOR_PASSWORD,
                "username": SMS_VENDOR_USERNAME, "sender": "MY_COMPANY"  }
        resp = requests.post(SMS_VENDOR_URL, json=task)
        if resp.status_code != 200:
function CleanCountryPage() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('C1').activate();
spreadsheet.getActiveRangeList().clear({contentsOnly: true, skipFilteredRows: true});
spreadsheet.getRange('E2').activate();
spreadsheet.getActiveRangeList().clear({contentsOnly: true, skipFilteredRows: true});
spreadsheet.getRange('E5').activate();
spreadsheet.getActiveRangeList().clear({contentsOnly: true, skipFilteredRows: true});
spreadsheet.getRange('E12').activate();
spreadsheet.getActiveRangeList().clear({contentsOnly: true, skipFilteredRows: true});
@sibil
sibil / PostgreSQL.txt
Created April 27, 2020 10:38
PostgreSQL commands
//switch user to postgres
sudo su postgres
//Reach psql
postgres@elcportal-dev:/var/www/local/hafiz/cli$ psql
//psql with params
psql -h hostname -U postgres
//clear screen