Skip to content

Instantly share code, notes, and snippets.

@piyushrajput
piyushrajput / http-errors.js
Created May 7, 2020 13:51 — forked from joyrexus/http-errors.js
HTTP Error classes in Node.js
'use strict';
const statusCodes = require('http').STATUS_CODES;
function createError(code, name) {
return function(message) {
Error.captureStackTrace(this, this.constructor);
this.name = name;
this.message = message;
this.statusCode = code;
}
@piyushrajput
piyushrajput / export_google_music.js
Created June 2, 2017 06:15 — forked from jmiserez/export_google_music.js
(fixed/updated 2016-05-10) Export your Google Music Library and Playlists (Google Play Music All Access) (see http://webapps.stackexchange.com/questions/50311/print-playlist-from-google-play-music for more)
// Jeremie Miserez <[email protected]>, 2016
//
// A little bit of Javascript to let you export your Google Music library, playlists, and album track lists :)
//
// I posted this as an answer here: http://webapps.stackexchange.com/questions/50311/print-playlist-from-google-play-music
//
// 1. Go to: https://play.google.com/music/listen#/all (or your playlist)
//
// 2. Open a developer console (F12 for Chrome). Paste
// code below into the console.
@piyushrajput
piyushrajput / BadgeUtils
Created November 26, 2015 13:19 — forked from Tadas44/BadgeUtils
Launcher icon notification for Samsung and Sony Xperia devices
public class BadgeUtils {
public static void setBadge(Context context, int count) {
setBadgeSamsung(context, count);
setBadgeSony(context, count);
}
public static void clearBadge(Context context) {
setBadgeSamsung(context, 0);
@piyushrajput
piyushrajput / swap.sh
Created November 20, 2015 05:22 — forked from peterchester/swap.sh
A simple little shell script that executes the digital ocean swap file tutorial.
#/bin/sh
# Creates a 1gb swap image.
# @see https://www.digitalocean.com/community/tutorials/how-to-configure-virtual-memory-swap-file-on-a-vps
if [ -f /var/swap.img ]; then
echo "Swap file already exists."
else
touch /var/swap.img
chmod 600 /var/swap.img
@piyushrajput
piyushrajput / ChangePassword.java
Created October 19, 2015 07:35 — forked from zach-klippenstein/ChangePassword.java
The keystore password on Java keystore files is utterly pointless. You can reset it without knowing it, as shown by this code. Note that private keys are still secure, as far as I know. The JKS implementation is copyright Casey Marshall ([email protected]), and the original source is available at http://metastatic.org/source/JKS.java. I've in…
import java.util.*;
import java.io.*;
import java.security.*;
public class ChangePassword
{
private final static JKS j = new JKS();
public static void main(String[] args) throws Exception
{
# search for feed items that match text and are parented by record_id,
# e.g. a specific group or record feed. page_size must be a number between
# 1 and 100. This method doesn't handle paging, so in most cases you'll want to also
# add a page parameter to the query and continue to page even though no posts appear
# for the searched group in some pages.
def self.search_feed(user, record_id, text, page_size=100)
escaped_text = URI.escape(text, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
items = Session.do_get(user, "/chatter/feed-items?q=#{escaped_text}&pageSize=#{page_size}")
# filter out items that are not part of the searched group
output = []
# helper that takes a feedItem hash and converts it to HTML, including
# properly structuring any included message segments like @mentions.
def message_segments(msg_segments)
# an array of hashes - each hash a segment
html = ''
msg_segments.each do |segment|
html << case segment['type']
when 'Text'
segment['text']
{
"instance_url": "https://na12.salesforce.com",
"items": [{
"parent": {
"name": "John Smith",
"title": null,
"firstName": "John",
"lastName": "Smith",
"companyName": "No company locations found",
"mySubscription": null,
authorization: OAuth 00DU0000000J83v!AQoAQJkLzYuCPmfyTZ7Mmg.Otq3W6klMTqqXUsTUdfwMtk8BcZJxpNdyCfUmm5.0Psfr8j7xDoNnRuV8u7UtANm.E_ubaXCB
x-chatter-entity-encoding: false
accept: */*
user-agent: Ruby
content-type: multipart/form-data; boundary=-----------RubyMultipartPost
content-length: 34684
-------------RubyMultipartPost
Content-Disposition: form-data; name="json"
Content-Type: application/json; charset=UTF-8
Content-Transfer-Encoding: 8bit
<apex:page controller="CustomerCommunityController" id="customercommunitycontroller" sidebar="false" showHeader="false" standardStylesheets="false" >
<head>
<title>Acme Customer Support</title>
<meta charset="utf-8" />
<apex:includeScript value="{!$Resource.jquery}"/>
</head>
<script type="text/javascript">