Skip to content

Instantly share code, notes, and snippets.

View halukugurlu's full-sized avatar
🏠

Haluk halukugurlu

🏠
View GitHub Profile
@halukugurlu
halukugurlu / escape.js
Last active April 6, 2021 14:36 — forked from mathiasbynens/escape.js
Escaping JSON-stringified data for use as a JavaScript string literal
// This object contains a string value that in contains a single quote,
// a double quote, a backtick, and a backslash.
const data = { foo: `a'b"c\`d\\e` };
// Turn the data into its JSON-stringified form.
const json = JSON.stringify(data);
// Now, we want to insert the data into a script body as a JavaScript
// string literal per https://v8.dev/blog/cost-of-javascript-2019#json,
// escaping special characters like `"` in the data.
@halukugurlu
halukugurlu / .eslintignore
Created September 22, 2020 21:08 — forked from heyitsarpit/.eslintignore
ESlint and Prettier for React apps (Bonus - Next.js and TypeScript)
node_modules
@halukugurlu
halukugurlu / cloudSettings
Last active October 29, 2021 12:55
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-10-29T12:55:00.638Z","extensionVersion":"v3.4.3"}
@halukugurlu
halukugurlu / link.txt
Created July 4, 2018 16:23
flexbox jsfiddle
{
"Ansi 6 Color" : {
"Green Component" : 0.5372549295425415,
"Red Component" : 0.11764705926179886,
"Blue Component" : 0.53333336114883423
},
"Tags" : [
],
"Ansi 12 Color" : {
@halukugurlu
halukugurlu / chrome-certerror-bypass
Created October 12, 2017 19:54
Allow Invalid Certs from Localhost (Chrome 61)
This option will only work for requests to localhost over HTTP.
In the Chrome address bar, type “chrome://flags/#allow-insecure-localhost“
Select the “Enable” link.
@halukugurlu
halukugurlu / react_data_async_with_xmlhttpreq.js
Last active September 21, 2017 19:21
REACT - async/await with XMLHttpRequest (request can be aborted if needed)
async componentDidMount() {
let response = await this.fetchAsync(this.props.url);
await this.setState({feed: response}); // fill the empty feed array in the state obj
console.info('bundle response',this.state.feed);
}
componentWillReceiveProps(nextProps) {
@halukugurlu
halukugurlu / getTimeStamp
Created August 30, 2017 21:19
Check server timestamp
// Check server time stamp agains current time zone
(function compareServerTimeStamp(){
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var time = Number(this.response.replace(/\D/g,'') + '000');
var date = new Date(time);
console.info("Current TimeStamp: ", time);
console.info("Current time at our zone: ", date);
console.info("Current UNIX time at server: ", date.toISOString());
@halukugurlu
halukugurlu / jsBindExamples.js
Last active July 7, 2017 21:46
Bind, Function Currying
var years = [1982, 1993, 1998, 1977, 1965, 1990];
//Single responsibility
//Just Calculate the given array data sets array
// depends on the type of calculation function being passed
function arrayCalc(arr, fn){
var arrRes = [];
for (var i = 0; i < arr.length; i++){
arrRes.push(fn(arr[i]));
}
@halukugurlu
halukugurlu / .gitignore
Created June 4, 2017 10:01
Git ignore file for JetBrains products
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/