This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requirements: | |
# - dnspython (`pip install dnspython`) | |
# CSV: | |
# - filename: emails.csv | |
# - column: "email" | |
import csv | |
import dns.resolver | |
from collections import Counter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function incrementAsync(n) { | |
return async (dispatch, getState) => { | |
console.log('initial count', getState().counter.count) | |
dispatch({ type: 'COUNTER_COUNTING', counting: true }) | |
for (let i = 1; i <= n; i++) { | |
dispatch({ type: 'COUNTER_INCREMENT', n: 1 }) | |
await new Promise(resolve => setTimeout(resolve, 500)) | |
} | |
dispatch({ type: 'COUNTER_COUNTING', counting: false }) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default prepareStore(initialState, { | |
// Action "incrementAsync" that increments multiple times | |
// We're using an async generator to yield multiple partial states | |
// and execute asynchronous operations | |
async *incrementAsync(n) { | |
// We can access the current state with "this" | |
// We shouldn't need this too often. It's like thunks' getState() | |
console.log('initial count', this.count) | |
// Instead of dispatching an action as w're used to with redux-thunk, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const initialState = { | |
count: 0, | |
counting: false | |
} | |
// Actions | |
export function reset() { | |
return { type: 'COUNTER_RESET' } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { prepareStore } from 'redux-zap' | |
const initialState = { | |
count: 0, | |
counting: false | |
} | |
export default prepareStore(initialState, { | |
// Action "reset" that set count to 0 | |
// We return a partial state that will be applied to the current state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'check_auth.php'; | |
$username = $_SESSION['username']; | |
// Cookie "visits" | |
if (isset($_COOKIE['visits']) && ctype_digit($_COOKIE['visits'])) { | |
$visits = $_COOKIE['visits'] + 1; | |
} else { | |
$visits = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# =============== # | |
# Unity generated # | |
# =============== # | |
/Temp/ | |
/Library/ | |
# ===================================== # | |
# Visual Studio / MonoDevelop generated # | |
# ===================================== # | |
ExportedObj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
## Instant backup of a MySQL database with LVM snapshot | |
## Author: Godefroy de Compreignac (@Godefroy) | |
## License: Beerware | |
# Instructions: | |
# - MySQL Data on DB server must be an logical LVM partition | |
# - Backup server must have ssh root access to DB server | |
# - Master status is saved at the exact moment of snapshot to allow restoration of master-slave replication |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function isBalanced($str){ | |
$count = 0; | |
$length = strlen($str); | |
for($i = 0; $i < $length; $i++){ | |
if($str[$i] == '(') | |
$count += 1; | |
else if($str[$i] == ')') | |
$count -= 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.removeAccents = function(){ | |
var t = this, | |
a = { | |
'œ' : 'oe', | |
'Œ' : 'Oe', | |
'æ' : 'ae', | |
'Æ' : 'Ae', | |
'[ÀÁÂÃÄÅĀĂǍẠẢẤẦẨẪẬẮẰẲẴẶǺĄ]' : 'A', | |
'[àáâãäåāăǎạảấầẩẫậắằẳẵặǻą]' : 'a', | |
'[ÇĆĈĊČ]' : 'C', |