Skip to content

Instantly share code, notes, and snippets.

View MohammadFakhreddin's full-sized avatar
🎓
Studying :))

Mohammad Fakhreddin MohammadFakhreddin

🎓
Studying :))
View GitHub Profile
@ZackAkil
ZackAkil / unity_save_camera_image.cs
Last active April 14, 2023 07:54
Unity code to save camera view to PNG image.
void Save_camera_image(Camera cam, string path){
// set render target to target texture
var currentRT = RenderTexture.active;
RenderTexture.active = cam.targetTexture;
// Make a new texture and read the active Render Texture into it.
Texture2D image = new Texture2D(cam.targetTexture.width, cam.targetTexture.height);
image.ReadPixels(new Rect(0, 0, cam.targetTexture.width, cam.targetTexture.height), 0, 0);
image.Apply();
@nihlton
nihlton / persisted-timeboxed-redux-store.js
Last active July 2, 2020 13:50
Persist Redux in localStorage, with an expiration schedule for each store key.
import { getInitialState, syncLocalStorageWithRedux } from './util-localStorage'
const reduxStorageKey = 'my-application:'
const ONE_SECOND = 1000
const ONE_MINUTE = ONE_SECOND * 60
const ONE_HOUR = ONE_MINUTE * 60
const ONE_DAY = ONE_HOUR * 24
const ONE_YEAR = ONE_DAY * 365
// create a white list. key is the redux store key, and lifeSpan is
@caiorss
caiorss / CMakeLists.txt
Created January 9, 2019 00:38
Example C++ project with Cmake + VCPKG package manager + Nana GUI library
cmake_minimum_required(VERSION 3.9)
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
message(" [INFO] VCPKG CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}")
endif()
#======= Global Project Configuration =========#
@m-tymchyk
m-tymchyk / is-iphone-x.js
Last active July 5, 2021 22:36
React Native / How to determine if on iPhone X or XR
// is-iphone-x.js
import { Dimensions, Platform } from 'react-native';
export function isIphoneX() {
const dim = Dimensions.get('window');
return (
// This has to be iOS
Platform.OS === 'ios' &&
@erikvullings
erikvullings / deep-copy.ts
Last active October 5, 2023 13:27
Deep copy or clone in TypeScript
/**
* Deep copy function for TypeScript.
* @param T Generic type of target/copied value.
* @param target Target value to be copied.
* @see Source project, ts-deepcopy https://github.com/ykdr2017/ts-deepcopy
* @see Code pen https://codepen.io/erikvullings/pen/ejyBYg
*/
export const deepCopy = <T>(target: T): T => {
if (target === null) {
return target;
# Blender v2.76 (sub 0) OBJ File: ''
# www.blender.org
mtllib cube.mtl
o Cube
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -0.999999
v 0.999999 1.000000 1.000001
@runspired
runspired / form.html
Created May 23, 2016 13:46
How to turn off password and email/username autocomplete.
<!--
<form autocomplete="off"> will turn off autocomplete for the form in most browsers
except for username/email/password fields
-->
<form autocomplete="off">
<!-- fake fields are a workaround for chrome/opera autofill getting the wrong fields -->
<input id="username" style="display:none" type="text" name="fakeusernameremembered">
<input id="password" style="display:none" type="password" name="fakepasswordremembered">
@Overv
Overv / HelloTriangle.cc
Created April 24, 2016 18:54
Vulkan hello triangle
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <chrono>
#include <functional>
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
@gavinengel
gavinengel / intro.md
Created February 25, 2016 22:57 — forked from gschema/intro.md
Basic JavaScript MVC Implementation

Basic JavaScript MVC Implementation

Despite being derived from classical MVC pattern JavaScript and the environment it runs in makes Javascript MVC implementation have its own twists. Lets see how typical web MVC functions and then dive into simple, concrete JavaScript MVC implementation.

How Web MVC typically works

Typical server-side MVC implementation has one MVC stack layered behind the singe point of entry. This single point of entry means that all HTTP requests, e.g. http://www.example.com or http://www.example.com/whichever-page/ etc., are routed, by a server configuration, through one point or, to be bold, one file, e.g. index.php.

At that point, there would be an implementation of Front Controller pattern which analyzes HTTP request (URI at first place) and based on it decides which class (Controller) and its method (Action) are to be invoked as a response to the request (method is name for function and member is name for a variable when part of the class/object).