Skip to content

Instantly share code, notes, and snippets.

View akhal3d96's full-sized avatar

Ahmed Khaled akhal3d96

View GitHub Profile
@akhal3d96
akhal3d96 / webkit.cs
Created October 2, 2012 20:45
WebKit Rendering Engine In MonoDevelop
SetDefaultSize(800,600);
ScrolledWindow scrol = new ScrolledWindow();
WebView webii = new WebView();
webii.Open("http://www.twitter.com");
fixed2.Add(scrol);
fixed2.Add(webii);
webii.SetSizeRequest(800,600);
fixed2.ShowAll();
@akhal3d96
akhal3d96 / gist:3839625
Created October 5, 2012 12:42
Kemia2y [issues #1]
int st = Array.IndexOf(element,findtxt); //رقم مكان القيمة المُدخلة في entry1
int sc = Array.IndexOf(element,findtxt2);//رقم مكان القيمة المُدخلة في entry2
if (sc == st)
{
sc = 1 ; st = 1;
label3.Text = element[st]+valency[sc]+" "+element[sc]+valency[st];
}
@akhal3d96
akhal3d96 / gist:3839691
Created October 5, 2012 12:58
Kemia2y - Function -
private void my()
{
string findtxt,findtxt2;
findtxt = entry1.Text;
findtxt2=entry2.Text;
string [] element = {"H","He","Li","Br","Be","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar","K","Ca"};
int [] valency = {1,0,1,2,3,4,3,2,1,0,1,2,3,4,5,2,1,0,1,2,};
@akhal3d96
akhal3d96 / gist:3842949
Created October 5, 2012 22:59
Kemia2y - Function #2 -
private void my()
{
//تعريف المُتغيرات
string findtxt,findtxt2;
findtxt = entry1.Text;
findtxt2=entry2.Text;
//المُتغير الفارغ :D
Nullable<int> i = null;
#!/usr/bin/python
import random
def Generate():
_1 = str(random.randint(0,9))
_2 = str(random.randint(0,9))
_3 = str(random.randint(0,9))
_4 = str(random.randint(0,9))
_5 = str(random.randint(0,9))
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int times[1000001],indst[1000001],inden[1000001],n,i,f,maxn,max;
maxn=-1;
scanf("%d",&n);
memset(times, 0, 1000001*sizeof(int));
for(i=0;i<n;i++)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 1000001
int main()
{
int size,i,x,most=-1,mostn,times[MAX],start[MAX],end[MAX];
[Trigger]
Type = File
Operation = Upgrade
Target = *
[Action]
When = PostTransaction
Exec = /etc/pacman.d/hooks/ruby-gems-update.sh
@akhal3d96
akhal3d96 / start_vpn.sh
Last active August 22, 2016 13:05
Quickly establish a connection with a free VPN server in USA in order to access Spotify's services
curl -o vpn.zip -s "https://www.vpnbook.com/free-openvpn-account/VPNBook.com-OpenVPN-US1.zip" && unzip vpn.zip -d ~/vpn_files && echo "vpnbook" > ~/.auth && curl -s "https://www.vpnbook.com/" | grep Password | tr -d '\t\n\r\f' | grep -Eo 'Password: [a-zA-Z0-9]*' | uniq | sed 's/Password: //' >> ~/.auth && sudo openvpn --config ~/vpn_files/vpnbook-us1-tcp443.ovpn --auth-user-pass ~/.auth
@akhal3d96
akhal3d96 / caitw.sh
Last active January 19, 2017 22:20
A simple script to convert the grabage you collect through the internet (aka memes) and other unimportant images you have to lossy webp image which will save you some space. Past it into a directory and it will compress anything in it. It's very destructive use it wisely.
#!/usr/bin/bash
BSIZE=$(du -Ss $PWD | awk '{print $1}')
function finish(){
ASIZE=$(du -Ss $PWD | awk '{print $1}')
FSIZE=$((BSIZE-ASIZE))
echo $(python -c "print($FSIZE/1000.0)")MB
}
trap finish EXIT
find $PWD -maxdepth 1 -size -1024k -iname "*.jpg" -or -iname "*.png" | xargs -I '{}' sh -c '(echo converting "{}" && cwebp "{}" -mt -q 80 -o "{}".webp 2> /dev/null || true) && rm "{}"'
#Remove -maxdepth 1 to make it recursive (NOT RECOMMENDED)