Skip to content

Instantly share code, notes, and snippets.

/**
* A bookmarklet for viewing the largest contentful paint in a page.
* Will show each LCP after the bookmarklet is clicked.
*
* To install:
* 1. Copy the code starting from the line beginning `javascript:`
* 2. Add a new bookmark in Chrome, and paste the code in as the URL.
**/
javascript:(function(){
try {
@mihaikelemen
mihaikelemen / configuration.yml
Created April 20, 2019 07:15
Redmine - Amazon SES (Simple Email Service) configuration
...
email_delivery:
delivery_method: :smtp
smtp_settings:
enable_starttls_auto: true
address: "AWS_SMTP_DOMAIN"
port: 587
domain: "REDMINE_DOMAIN"
authentication: :login
user_name: "YOUR_SMTP_USER"
@nczz
nczz / mxp-mitake-sms.php
Last active April 15, 2024 16:09
WordPress 三竹簡訊發送外掛
<?php
/*
Plugin Name: 三竹簡訊 Webhook
Plugin URI: https://gist.github.com/nczz/750c3d8d18b9e0ca07ca06a248c11570
Description: 接收 Webhook 請求發送簡訊
Author: Chun
Version: 1.0
Author URI: https://www.mxp.tw/
*/
/**
* Summernote StripTags
*
* This is a plugin for Summernote (www.summernote.org) WYSIWYG editor.
* To strip unwanted HTML tags and attributes while pasting content in editor.
*
* @author Hitesh Aggarwal, Extenzine
*
*/
@singhmohancs
singhmohancs / form-Auto-fill-Fix.directive.js
Created January 19, 2018 08:24
Fix autocomplete (autofill) form in Angular
angular.module('A').directive('formAutofillFix', function ($timeout) {
return function (scope, element, attrs) {
element.prop('method', 'post');
if (attrs.ngSubmit) {
$timeout(function () {
element
.unbind('submit')
.bind('submit', function (event) {
event.preventDefault();
element
@customcommander
customcommander / browser_logs-chrome.js
Created May 25, 2017 09:13
Capture console.log() output from a web page with Selenium WebDriver 2.53 and Chrome
require('chromedriver');
const path = require('path');
const wd = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
var builder = new wd.Builder();
var options = new chrome.Options();
var prefs = new wd.logging.Preferences();
var driver;
@fgilio
fgilio / axios-catch-error.js
Last active April 11, 2024 19:02
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@jbreckmckye
jbreckmckye / AjaxTextureLoader.js
Created April 11, 2017 13:23
Loading THREE textures with onProgress events
const THREE = require('three');
function AjaxTextureLoader() {
/**
* Three's texture loader doesn't support onProgress events, because it uses image tags under the hood.
*
* A simple workaround is to AJAX the file into the cache with a FileLoader, then extract that into a
* texture with a separate TextureLoader call.
*/
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@AshikNesin
AshikNesin / react-file-upload.js
Created February 2, 2017 06:46
Simple React File Upload
import React from 'react'
import axios, { post } from 'axios';
class SimpleReactFileUpload extends React.Component {
constructor(props) {
super(props);
this.state ={
file:null
}