Skip to content

Instantly share code, notes, and snippets.

View esnosy's full-sized avatar

Eyad Ahmed esnosy

  • Egypt
  • 14:45 (UTC +03:00)
View GitHub Profile
@esnosy
esnosy / MoveCamera.cs
Created July 13, 2017 06:46 — forked from JISyed/MoveCamera.cs
Camera movement script in Unity3D. Supports rotating, panning, and zooming. Attach to the main camera. Tutorial explaining code: http://jibransyed.wordpress.com/2013/02/22/rotating-panning-and-zooming-a-camera-in-unity/
// Credit to damien_oconnell from http://forum.unity3d.com/threads/39513-Click-drag-camera-movement
// for using the mouse displacement for calculating the amount of camera movement and panning code.
using UnityEngine;
using System.Collections;
public class MoveCamera : MonoBehaviour
{
//
// VARIABLES
@esnosy
esnosy / index.html
Created July 20, 2019 16:10
Prayer Times using API
<iframe id="iframe3" style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px solid rgb(238, 238, 238); width: 100%; overflow: hidden; height: 199px;" src="https://timesprayer.today/widget_frame.php?frame=3&amp;id=564&amp;sound=false"></iframe>
@esnosy
esnosy / linsolve.py
Last active November 25, 2019 23:45
parse linear equation string and solve for x
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 17 05:15:31 2019
@author: Iyad
"""
def dif(f, x, h = .001):
return (f(x+h)-f(x))/h
def nsolve(f, err = .001):
x = 0
@esnosy
esnosy / redirect.html
Created December 4, 2019 19:20
Simple JavaScript redirect
<script>
window.location.assign("https://www.google.com")
</script>
<div dir="rtl" style="text-align: right;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
</div>
@esnosy
esnosy / main.cpp
Last active December 4, 2019 22:10
simple calculator with numerical input and zero division checks
#include <iostream>
using namespace std;
float safein(){
float n;
cout << "Enter a number: ";
while (!(cin >> n)){
cout << "ERR: NOT A NUMBER!" << endl;
cin.clear();
cin.ignore(256, '\n');
}
@esnosy
esnosy / main.cpp
Created December 9, 2019 00:14
simple_area_calculator
#include <iostream>
using namespace std;
const float pi = 3.14159265359;
float safein(string ask){
float n;
cout << ask;
while (!(cin >> n)){
cout << "ERR: NOT A NUMBER!" << endl;
cin.clear();
cin.ignore(256, '\n');
@esnosy
esnosy / main.cpp
Created December 10, 2019 20:13
Factorial calculator with *safe input and overflow check
#include <iostream>
#include <cmath>
using namespace std;
double safein(string ask){
cout << ask << endl;
double x;
while(!(cin >> x) || x - floor(x)){
cout << "Not an integer!\n";
cin.clear();
cin.ignore(256,'\n');
@esnosy
esnosy / vscuda8fix.py
Last active August 16, 2020 15:06
Fix CUDA 8 projects to work with Visual Studio 2017-2019+
# the code is ugly I know
import sys
import os
if (len(sys.argv)> 1):
file = sys.argv[1]
if file.endswith(".vcxproj"):
def fix(file):
with open(file) as proj:
@esnosy
esnosy / series_decompose.py
Last active January 26, 2021 13:43
Decompose a series as a sum of arthimetic and geometric series
'''Copyright 2019-2020 Iyad Ahmed
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE O
@esnosy
esnosy / batch_psd_to_png.py
Last active April 20, 2021 22:04
Batch convert psd files in current directory to png, requires psd-tools
from psd_tools import PSDImage
import os
for f in os.scandir():
if f.is_file():
if f.name.endswith(".psd"):
psd = PSDImage.open(f.name)
psd.composite().save(f.name[:-4]+".png")