Skip to content

Instantly share code, notes, and snippets.

View petitroto's full-sized avatar

NAKAMURA Masayuki petitroto

View GitHub Profile
@uemuraj
uemuraj / aws-route53-auth.sh
Last active July 27, 2020 00:52
Let's EncryptのDNS-01方式をAamzon Route 53 で認証して無料のSSL証明書を取得する
#!/bin/bash
./aws-route53-change-resource-record-sets.sh ${CERTBOT_DOMAIN#*.} << EOF
{
"Changes":[ { "Action":"CREATE", "ResourceRecordSet":{"Name":"_acme-challenge.${CERTBOT_DOMAIN}", "Type":"TXT", "TTL":300, "ResourceRecords":[{"Value": "\"${CERTBOT_VALIDATION}\""}] } } ]
}
EOF
@karol-majewski
karol-majewski / flatMap.ts
Last active February 2, 2023 13:48
The simplest flatMap implementation in TypeScript
export function flatMap<T, U>(array: T[], callbackfn: (value: T, index: number, array: T[]) => U[]): U[] {
return Array.prototype.concat(...array.map(callbackfn));
}
@miz21358
miz21358 / template.json
Created January 16, 2018 06:35
Elasticsearch+kuromoji-neologd で品詞分解アナライザを設定したテンプレート設定用JSONファイル
{
"sample-analyze": {
"order": 0,
"template": "sample-analyze-*",
"settings": {
"index": {
"analysis": {
"filter": {
"greek_lowercase_filter": {
"type": "lowercase",
@awestover89
awestover89 / lambda.js
Last active April 23, 2018 06:57
Node.js lambda function for gw_proxy
var http = require('http');
var https = require('https');
var util = require('util');
exports.handler = function(event, context, callback) {
console.log(util.inspect(event, 3));
console.log(util.inspect(context, 3));
// setup request options and parameters
var options = {
@QuantumGhost
QuantumGhost / example.puml
Last active September 21, 2024 19:19
A simple template for PlantUML to draw ER diagram.The basic idea comes from http://plantuml.sourceforge.net/qa/?qa=331/database-modeling
@startuml
' uncomment the line below if you're using computer with a retina display
' skinparam dpi 300
!define Table(name,desc) class name as "desc" << (T,#FFAAAA) >>
' we use bold for primary key
' green color for unique
' and underscore for not_null
!define primary_key(x) <b>x</b>
!define unique(x) <color:green>x</color>
!define not_null(x) <u>x</u>
@pulkitsinghal
pulkitsinghal / notes.md
Last active February 8, 2019 18:00
Loopback: How to log any errors via a global error handler?

Pitfalls

The REST adapter for strong-remoting sets up its own error handler! So you cannot accomplish this for REST API related calls by replacing:

  1. app.use(loopback.errorHandler()); in server/server.js
  2. or, loopback#errorHandler in middleware.json

So don't waste your time there.

Deeper Understanding

@zackkatz
zackkatz / gravityview-no-entries-text-show-form.php
Created July 24, 2015 16:55
GravityView - Show contact form when there are no entries in a View
<?php
add_filter( 'gravitview_no_entries_text', 'add_form_to_gravitview_no_entries_text', 10, 2 );
/**
* Modify the text displayed when there are no entries to show a Gravity Forms form
*
* @param string $output The existing "No Entries" text
* @param boolean $is_search Is the current page a search result, or just a multiple entries screen?
*/
@pulkitsinghal
pulkitsinghal / my-model.js
Last active September 20, 2018 05:53
Non-Static (instance) remote methods for loopback
var loopback = require('loopback');
// HINT(s):
// Getting the app object: http://docs.strongloop.com/display/public/LB/Working+with+LoopBack+objects
// From a model script: http://docs.strongloop.com/display/public/LB/Working+with+LoopBack+objects#WorkingwithLoopBackobjects-Fromamodelscript
module.exports = function(StoreModel) {
StoreModel.prototype.instanceRemoteMethodSignature = function(cb) {
console.log('print this instance object: ', this);
cb(null);
};
@bitmage
bitmage / afterCreate.js
Last active February 16, 2017 01:01
Loopback Model - afterCreate hook to auto-save related models instantiated using build()
var async = require('async');
Project.afterCreate = function(done) {
var self = this;
function createRelation(rel, next, name) {
self[name].create(rel, next);
};
objMapAsync(this.__cachedRelations, createRelation, done);
@subfuzion
subfuzion / redis-autostart-osx.md
Last active April 26, 2024 21:40
redis auto start OS X

Install with Homebrew

brew install redis

Set up launchctl to auto start redis

$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

/usr/local/opt/redis/ is a symlink to /usr/local/Cellar/redis/x.y.z (e.g., 2.8.7)