Skip to content

Instantly share code, notes, and snippets.

View ilhantekir's full-sized avatar
🏠
Working from home

ilhan Tekir ilhantekir

🏠
Working from home
  • Erka Grup
  • istanbul
View GitHub Profile
@ilhantekir
ilhantekir / gist:7145c9cc7b4f2bc44ae10b466f905e07
Created November 22, 2018 11:14
JQuery to check for duplicate ids in a DOM
$('[id]').each(function(){
var ids = $('[id="'+this.id+'"]');
if(ids.length>1 && ids[0]==this)
console.warn('Multiple IDs #'+this.id);
});
In web design sometimes you need an «empty» pixel to scale it to the desired length. For this matter I have gathered GIF and PNG both 100% transparent and white (it turns out this has some impact on the file size).
The PNGs have been ran through PNGOutWin. JPEGs I could get were above 1 KiB and for this reason are not considered.
Get all images in this archive.
Details
GIF
The winner is 1-color GIF – 35 bytes. Data URI for white 1×1 image:
PARENT
func = (smh) => {
alert(smh)
}
<ChildComponent func={this.func} />
CHILD
pressHandler(smh) {
class ItemViewComponent extends React.Component {
render() {
return ( <View> {this.displayJsxMessage()} </View> );
}
displayJsxMessage() {
return {this.props.isGreeting && <Text> Hello, JSX! </Text>}
}
}
@ilhantekir
ilhantekir / toggle-remote-styles.js
Created July 28, 2018 11:56 — forked from gauntface/toggle-remote-styles.js
A book marklet to toggle styles.
javascript:(function(){var styles = document.querySelectorAll('link[rel=\'stylesheet\']'); for (var s = 0; s < styles.length; s++) {styles[s].mediax = styles[s].media;if (styles[s].media === 'only x') { styles[s].media = styles[s].mediax; } else if (styles[s].media !== 'print') {styles[s].media = 'only x';}}})();
@ilhantekir
ilhantekir / Events bound on an element with jQuery
Last active May 16, 2018 12:10
Events bound on an element with jQuery
// Bind up a couple of event handlers
$("#foo").on({
click: function(){ alert("Hello") },
mouseout: function(){ alert("World") }
});
// Lookup events for this particular Element
$._data( $("#foo")[0], "events" );

Gradient shadow in pure CSS

alt text

HTML
<button>Let's Go !</button>
@ilhantekir
ilhantekir / domIsReady.js
Created January 15, 2018 06:26 — forked from devbyray/domIsReady.js
Vanilla JavaScript Document Ready (Cross-Browser)
var domIsReady = (function(domIsReady) {
var isBrowserIeOrNot = function() {
return (!document.attachEvent || typeof document.attachEvent === "undefined" ? 'not-ie' : 'ie');
}
domIsReady = function(callback) {
if(callback && typeof callback === 'function'){
if(isBrowserIeOrNot() !== 'ie') {
document.addEventListener("DOMContentLoaded", function() {
return callback();
$(“[attribute|=’value’]”) — The “attribute contains prefix selector” returns all elements with attributes whose value is equal to or starts with the given string followed by a hyphen.
$(“[attribute*=’value’]”) — This “attribute contains selector” returns all elements with attributes whose value contains the given substring. The location of the value doesn’t matter. As long as it matches with the given value the selector will select the element.
$(“[attribute~=’value’]”) — This selector returns all elements with attributes whose value contains a given word delimited by spaces.
$(“[attribute$=’value’]”) — This selector returns all elements with attributes whose value ends with the given string.
$(“[attribute=’value’]”) — This selector returns all elements with attributes whose value is exactly equal to a given string.
@ilhantekir
ilhantekir / canvas-upload.php
Created July 16, 2017 12:35 — forked from fazlurr/canvas-upload.php
Function to save base64 image to png with PHP
<?php
// requires php5
define('UPLOAD_DIR', 'images/');
$img = $_POST['img'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
$success = file_put_contents($file, $data);
print $success ? $file : 'Unable to save the file.';