Skip to content

Instantly share code, notes, and snippets.

View pajtai's full-sized avatar

Peter Ajtai pajtai

  • https://www.soliddigital.com/
  • Portland, Oregon
View GitHub Profile
@pajtai
pajtai / instructions.md
Last active May 29, 2023 12:13
Debugging Node with Webstorm running on a remote server

Debugging node running on a remote server

Node uses a TCP interface for debugging, so if you can get a handle on the right port, you can debug apps running remotely. This means you can run through code on staging, Vagrant, etc. The following shows you how to start node with the debug flag and use an SSH tunnel to access the right port.

Things you need:

  • ssh access to the server
  • ability to restart node app with --debug flag or node-inspector installed on server

Debugging using Webstorm

@pajtai
pajtai / svn-to-git.md
Created October 12, 2012 16:12
3 steps for migrating from SVN to GIT

3 steps for migrating from SVN to GIT

assuming password protected svn repo with standard trunk, branches, tags setup

Step 1

svn2git http://svn.example.com/path/to/repo --username [USERNAME] --verbose
const app = {};
consign()
.include('api')
.into(app);
const flattened = flatten(app);
Object.entries(flattened).forEach(([route, router]) => {
const baseRoute = `/${route.replace(/\.controller$/, '').replace(/\./g, '/')}`;
'use strict';
const mongoose = require('mongoose');
module.exports = (app) => {
const tasksSchema = mongoose.Schema({
title: String,
done: {
type: Boolean,
'use strict';
const express = require('express');
module.exports = (app) => {
const router = express.Router();
router.get('/', (req, res) => {
'use strict';
const express = require('express');
const { version } = require('../package');
module.exports = () => {
const router = express.Router();
router.get('/', (req, res) => {
@pajtai
pajtai / controller.js
Last active May 4, 2018 20:27
A minimal express controller
'use strict';
const express = require('express');
module.exports = () => {
const router = express.Router();
router.get('/', (req, res) => {
res.json([]);
});
'use strict';
require('dotenv').config();
const express = require('express');
const app = express();
const helmet = require('helmet');
const pino = require('pino');
const logger = pino({
level: process.env.LOG_LEVEL
@pajtai
pajtai / modify-query.php
Last active April 4, 2018 14:56
modify core query
<?php
add_action('pre_get_posts', function($query) {
if ($query->is_home() && $query->is_main_query()) {
$query->set('posts_per_page', 8);
$currentMarket = get_query_var('market');
$currentCategory = get_query_var('category');
$taxQuery = getTaxonomyQuery($currentMarket, $currentCategory);
if ($taxQuery) {