Skip to content

Instantly share code, notes, and snippets.

View pulkitsinghal's full-sized avatar

Pulkit Singhal pulkitsinghal

View GitHub Profile
@pulkitsinghal
pulkitsinghal / README.md
Last active May 13, 2024 09:40
How can a nodejs process running inside a docker container, get that container's id?

Problem

How can a nodejs process running inside a docker container, get that container's id?

Solution

the hostname seems to be the short container id in Docker v1.12

It works and this idea was found in this SO post.

@pulkitsinghal
pulkitsinghal / shortcuts.md
Last active May 14, 2023 12:07
mac: WebStorm to Visual Studio (VSCode) key mappings

key mappings, keybindings, keyboard shortcuts

https://github.com/Microsoft/vscode-tips-and-tricks

Command: workbench.action.quickOpen

WebStorm: cmd+o VSCode: cmd+e

Command: collapse/fold all code blocks

WebStorm: cmd shift - VSCode: fold level 1 cmd+K cmd+1

@pulkitsinghal
pulkitsinghal / JCETest.java
Created March 5, 2013 18:39
Find out if the jar files required for JCE unlimited strength are present and in use on your machine or not.
import javax.crypto.Cipher;
public class JCETest {
public static void main(String[] args) throws Exception {
boolean limit = Cipher.getMaxAllowedKeyLength("RC5")<256;
System.out.println(limit);
}
}
@pulkitsinghal
pulkitsinghal / sample.js
Last active April 16, 2021 02:53
Add user to role in Parse
var rolesQuery = new Parse.Query(Parse.Role);
rolesQuery.equalTo('name', 'someRole');
return rolesQuery.first({useMasterKey:true})
.then(function(roleObject){
var user = new Parse.User();
user.id = req.params.userId;
roleObject.getUsers().add(user);
return roleObject.save(null, {useMasterKey:true});
});
@pulkitsinghal
pulkitsinghal / pom.xml
Created May 22, 2014 16:49
Extend classes generated by cxf-codegen-plugin usign the fluent plugin
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-wsdl-sources</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
@pulkitsinghal
pulkitsinghal / customBindingFile.xjb
Created December 28, 2013 19:41
How to get Java POJOs, generated from schema files, to implement custom interfaces via maven plugins
<?xml version="1.0"?>
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
jxb:extensionBindingPrefixes="xjc">
<jxb:bindings schemaLocation="../schema/yourSchemaFile.xsd">
<jxb:bindings node="//xs:complexType[@name='SomeElementNameFromYourSchemaFile']">
@pulkitsinghal
pulkitsinghal / gist:1932711
Created February 28, 2012 13:59
Ramping Up on ElasticSearch Query DSL
// 1) Lets start with the simplest query that you can run in
// the head plugin for ElasticSearch located at the url:
// http://localhost:9200/_plugin/head/
{
"query": {
"match_all": {}
}
}
// 2) Before jumping into forming queries with the ES Query DSL
@pulkitsinghal
pulkitsinghal / container.js
Last active September 19, 2019 22:40
Hooks for loopback file storage: after/before uploads, downloads etc.
/**
* Want to search github for sample code?
* Use the following `search criteria` in the github.com `search box` and then select `Code` from the search results:
* container upload remote language:javascript path:/common/models
*/
module.exports = function(Container) {
Container.beforeRemote('**', function(ctx, unused, next) {
console.log('4: good');
console.log('5: ctx.methodString', ctx.methodString);
@pulkitsinghal
pulkitsinghal / release-candidate.mermaid
Last active February 19, 2019 13:03
Workflow for a Release Candidate in Git
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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