Skip to content

Instantly share code, notes, and snippets.

@Evavic44
Evavic44 / domain.js
Last active October 30, 2024 18:13
A list of popular email domains (TLDs) - 2023
const domains = [
"gmail.com",
"yahoo.com",
"hotmail.com",
"aol.com",
"hotmail.co.uk",
"hotmail.fr",
"msn.com",
"yahoo.fr",
"wanadoo.fr",
@paulosuzart
paulosuzart / ReduxFetcher.js
Last active January 6, 2021 05:52
a simple abstraction for fetching, updating and filtering objects with correspondending state.
import {
XPTOService
} from '../services'
import { loginFailed } from './index.js'
const initial = {
filtering: {
data: []
},
listing: {}
@kamikat
kamikat / image64.sh
Last active January 31, 2024 06:08 — forked from puppybits/image64.sh
Create data URI image from Terminal command
#!/bin/sh
# Examples:
# ./image64.sh myImage.png
# outputs: data:image/png;base64,xxxxx
# ./image64.sh myImage.png -img
# outputs: <img src="data:image/png;base64,xxxxx">
append=""
if [[ "$1" == *.gif ]]; then
@benbacardi
benbacardi / templatetags.py
Last active August 25, 2024 23:07
Django query_transform templatetag
from django import template
register = template.Library()
@register.simple_tag(takes_context=True)
def query_transform(context, **kwargs):
'''
Returns the URL-encoded querystring for the current page,
updating the params with the key/value pairs passed to the tag.
@gaearon
gaearon / connect.js
Last active November 14, 2024 08:35
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@torgeir
torgeir / react-scaled-file-upload.js
Created March 25, 2015 12:16
React scaled file upload
function resize (file, maxWidth, maxHeight, fn) {
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function (event) {
var dataUrl = event.target.result;
var image = new Image();
image.src = dataUrl;
image.onload = function () {
@sandervm
sandervm / commandline.txt
Last active April 22, 2022 15:15
Generate Django secret key commandline
$ python -c 'import random; print "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])'
@summatix
summatix / remove_hashtags.php
Created December 16, 2014 20:44
PHP: Remove hashtags from a caption
<?php
/**
* Removes hashtags from the given text. Hashtags at the end of the text are removed,
* and hashtags within the text are unhashed.
*
* E.g.
* Case 1: This is an example with lots of hashtags at the end #hash1 #hash2 #hash3 #hash4 #hash5
* Result: This is an example with lots of hashtags at the end
*
@zlove
zlove / jquery.bxslider-alt.js
Last active January 24, 2018 19:58
Wrap bxSlider so that we can override options per slider with data attributes.
;(function ($) {
/**
* Return an object consisting of properties of 'data'
* that match the regex 'pattern'. If trim is not false,
* trim the matched 'pattern' from the property name,
* and make the first char of the remaining property
* name lowercase.
*/
function filterData(data, pattern, trim) {
var data,
@jtangelder
jtangelder / PreventGhostClick.js
Last active January 17, 2024 21:55
PreventGhostClick
/**
* Prevent click events after a touchend.
*
* Inspired/copy-paste from this article of Google by Ryan Fioravanti
* https://developers.google.com/mobile/articles/fast_buttons#ghost
*
* USAGE:
* Prevent the click event for an certain element
* ````
* PreventGhostClick(myElement);