Skip to content

Instantly share code, notes, and snippets.

@saitergun
saitergun / Debounce.vue
Created January 5, 2020 01:57
vue.js debouncing method
<template>
<input type="text" v-model="query" @input="search" />
</template>
<script>
export default {
name: 'Debounce',
data: () => ({
query: null,
@saitergun
saitergun / timeline.html
Created February 27, 2020 13:50
timeline placeholder
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Timeline</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/tailwind.min.css" />
</head>
<body class="bg-gray-100">
<span id="app">
<template>
<span>
<!-- credits from https://github.com/vuejs/vuex/issues/863#issuecomment-329510765 -->
</span>
</template>
<script>
import { mapState, mapActions, mapMutations } from 'vuex';
export default {
@saitergun
saitergun / index.html
Created March 26, 2020 08:04
axios cancel request
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>axios cancel</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/tailwind.min.css" />
</head>
<body class="pt-12">
<div id="app">
@saitergun
saitergun / README.md
Last active May 24, 2020 12:53 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

DB::connection()->getPdo()->sqliteCreateFunction('REGEXP', 'preg_match', 2);
DB::table('tablename')->whereRaw('lower(tablecolumn) REGEXP "'.$regex.'"');
@saitergun
saitergun / index.js
Last active April 4, 2022 18:04
catch url changes with javascript credit https://stackoverflow.com/a/52809105/5765524
// history.pushState = ( f => function pushState(){
// var ret = f.apply(this, arguments);
// window.dispatchEvent(new Event('pushstate'));
// window.dispatchEvent(new Event('locationchange'));
// return ret;
// })(history.pushState);
// history.replaceState = ( f => function replaceState(){
// var ret = f.apply(this, arguments);
// window.dispatchEvent(new Event('replacestate'));
// select the target node
var target = document.querySelector('title')
// create an observer instance
var observer = new MutationObserver(function(mutations) {
// We need only first event and only new value of the title
console.log('title changes', document.title)
})
// configuration of the observer:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<pre></pre>
const string2Hue = (string) => {
let hash = 0;
for (let i = 0; i < string.length; i += 1) {
hash = string.charCodeAt(i) + hash + (hash % 360);
}
return hash % 360;
}