Skip to content

Instantly share code, notes, and snippets.

@santaklouse
santaklouse / filters.js
Created September 11, 2018 16:36
AngularJS filters example
(function(angular) {
'use strict';
angular.module('unknown.filters', ['unknown.services'])
.filter('formatMinutes', ['dateUtils', function(dateUtils) {
return function(minutes, leadingZero) {
if (_.isUndefined(leadingZero)) {
leadingZero = true;
}
@santaklouse
santaklouse / cache.ts
Created September 11, 2018 16:51
Example of NodeJS code (TypeScript)
import * as log4js from "log4js";
import { AppCache as IAppCache, CacheState } from "../api";
const logger = log4js.getLogger("main.app.cache");
export class AppCache implements IAppCache {
public id: number = 1;
public state: CacheState;
// To check if the current record is from cache
@santaklouse
santaklouse / AddressParser.php
Created September 21, 2018 15:01
Example of XML parsing on PHP (Laravel)
<?php
namespace App\Parsers;
class AddressParser
{
private static $uniqueInstance = null;
protected function __construct()
mysqldump dev -d --skip-add-drop-table --add-drop-table=false > dev.sql
mysqldump live -d --skip-add-drop-table --add-drop-table=false > live.sql
perl -pi -e 's/^--.*\n//;s{/\*.*\*/;\n?}{}' dev.sql live.sql
diff -B -U 5 dev.sql live.sql > schema.diff
@santaklouse
santaklouse / gist:4ee570fbe105f2100fd06180aee03154
Created November 22, 2018 09:37
http-ping - check site availability (thru TOR as socks5 proxy)
httping -h $(tor-resolve ya.ru) -x localhost:9050 -5
@santaklouse
santaklouse / elastic-client.js
Last active November 23, 2018 14:34
NodeJs script for ElasticSearch to MongoDB Import
const elasticClient = require( "elasticsearch" );
// Set global base url for later use in importing scripts
const path = require("path");
const config = require( path.join( __dirname, "config" ) );
/*
* ElasticSearch init section
*/
const ESClient = new elasticClient.Client( {
host: config.esHosts,
requestTimeout: 1000 * 60 * 60,
@santaklouse
santaklouse / copymysql.sh
Created November 23, 2018 16:54 — forked from ecdundar/copymysql.sh
Copy MySQL Database One Server (Remote) To Another (Local) Server
#!/bin/bash
# copymysql.sh
# GENERATED WITH USING ARTUR BODERA'S SCRIPT
# Source script at: https://gist.github.com/2215200
MYSQLDUMP="/usr/bin/mysqldump"
MYSQL="/usr/bin/mysql"
@santaklouse
santaklouse / ngrok-selfhosting-setup.md
Created November 28, 2018 19:36 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#private-networks
https://github.com/ipfs/js-ipfs/blob/master/examples/custom-libp2p/index.js
https://github.com/ahester57/ipfs-private-swarm
https://stackoverflow.com/questions/46291766/private-network-with-ipfs-not-working
https://docs.ipfs.io/reference/api/cli/#ipfs-swarm
https://github.com/ipfs/js-ipfs
@santaklouse
santaklouse / LoginPage.jsx
Last active December 14, 2018 13:37
ReactJS code example
import React from 'react';
import { connect } from 'react-redux';
import { userActions } from '../actions';
class LoginPage extends React.Component {
constructor(props) {
super(props);
this.props.dispatch(userActions.logout());