Skip to content

Instantly share code, notes, and snippets.

@IgorDePaula
IgorDePaula / cpf.js
Last active November 3, 2021 13:40
vee-validate em pt-br
function calcChecker1 (firstNineDigits) {
let sum = null
for (let j = 0; j < 9; ++j) {
sum += firstNineDigits.toString().charAt(j) * (10 - j)
}
const lastSumChecker1 = sum % 11
const checker1 = (lastSumChecker1 < 2) ? 0 : 11 - lastSumChecker1
@josephspurrier
josephspurrier / etc-init.d-hello-world
Last active May 15, 2021 17:14
/etc/init.d Script for Go Application
#!/bin/bash
#
# chkconfig: 35 95 05
# description: Hello world application.
# Run at startup: sudo chkconfig hello-world on
# Load functions from library
. /etc/init.d/functions
@chen206
chen206 / memo.md
Last active December 5, 2023 18:10
Logrotate and upload Nginx logfile to S3

安装awscli

sudo apt-get install -y awscli

测试

sudo logrotate -d -f /etc/logrotate.d/nginx

触发logrotate

sudo logrotate -f /etc/logrotate.d/nginx

These examples are presented in an attempt to show how each coding styles attempts to or does not attempt to isolate side-effects. There are only 2 semantic elements in a barebone "Hello World" implementation:

  • Invocation of console.log
  • Declaration of HELLO_WORLD

Since every coding style can abstract away data into a parameter or variable, there is no point for us to show that. All implementations assume HELLO_WORLD is a constant that is always inlined. This way it reduces the variations we need to present. (To make an anology, if we were to implement incrementByOne, would we need to inline the number 1 or pass it in as parameter?)

CAVEAT/LIMITATION: All implementations also assume console is static global. In case of functional programming, console.log is asumed to be a function that can be passed around without further modification. (This is not the case in the browser, but that can be resolved with console.log.bind(console))

Declarative

@petcarerx
petcarerx / typescript_cheatsheet.ts
Created March 16, 2016 15:42
Typescript Cheat Sheet - Syntax features and examples
// _____ __ _ _
///__ \_ _ _ __ ___/ _\ ___ _ __(_)_ __ | |_
// / /\/ | | | '_ \ / _ \ \ / __| '__| | '_ \| __|
// / / | |_| | |_) | __/\ \ (__| | | | |_) | |_
// \/ \__, | .__/ \___\__/\___|_| |_| .__/ \__|
// |___/|_| |_|
//Typescript Cheat Sheet: every syntax feature exemplified
//variables are the same as javascript, but can be defined with a type:
var myString:string;
@chwnam
chwnam / entry-points.php
Created June 12, 2015 10:35
워드프레스 주요 진입점 (admin_menu, admin-post, ajax, redirect)에 대한 예제입니다. 소스는 실습용이므로 수정이 필요합니다.
<?php
/**
* Plugin Name: entry-points-<author>
*/
// Menu entry points
add_action( 'admin_menu', 'i_need_your_callback_selection' );
function <author>_entry_points_add_admin_menu() {
<?php
////////////////////////////
# WP AJAX EXAMPLE
////////////////////////////
/////////////////////////
# Enqueue Script
/////////////////////////
@lukecarbis
lukecarbis / frontend-ajax.php
Created October 28, 2014 19:23
WordPress AJAX Frontend Execution
<?php
/**
* WordPress AJAX Frontend Execution.
*
* Using WP Ajax should not be used from the frontend because response
* from `admin-ajax.php` are not cached (including `nocache_headers()`).
* Instead, you should add a query var, and then do the `template_include`
* routine to select a template that returns JSON.
*
* A side benefit here is that it makes your site more RESTful.
@syhw
syhw / dnn.py
Last active June 23, 2024 04:13
A simple deep neural network with or w/o dropout in one file.
"""
A deep neural network with or w/o dropout in one file.
License: Do What The Fuck You Want to Public License http://www.wtfpl.net/
"""
import numpy, theano, sys, math
from theano import tensor as T
from theano import shared
from theano.tensor.shared_randomstreams import RandomStreams
<?php
$category = 8;
$data = array(
164, 150, 132, 144, 125, 149, 145, 146,
158, 140, 147, 136, 148, 152, 144, 168,
126, 138, 176, 163, 119, 154, 165, 146,
173, 142, 147, 135, 153, 140, 135, 161,
145, 135, 142, 150, 156, 145, 128, 157
);
$min = min($data);