Skip to content

Instantly share code, notes, and snippets.

@piyushrajput
piyushrajput / resetSoft.sh
Created April 28, 2016 12:50
Git command to revert last commit without loosing your changes if its not pushed to server yet.
git reset HEAD~1 --soft
Disable gulp-notify
If you are running on a system that handles notifications poorly or you simply do not wish to use gulp-notify but your project does? You can disable gulp-notify by using enviroment variable DISABLE_NOTIFIER.
export DISABLE_NOTIFIER=true;
@piyushrajput
piyushrajput / CodeShipBuild.sh
Created April 3, 2016 10:43
Build UI on Codeship
# By default we use the Node.js version set in your package.json or the latest
# version from the 0.10 release
#
# You can use nvm to install any Node.js (or io.js) version you require.
# nvm install 4.0
# rm -Rf node_modules
nvm install 0.10
npm install -q
npm install -g [email protected] -q
npm install gulp -q
@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 / open-dev-console-in-new-window.js
Created October 27, 2015 11:08
Change the dev console link to open in new tab
x = document.getElementsByClassName("debugLogLink");
y = decodeURIComponent(x[0].getAttribute("href"));
z = y.substring(y.indexOf("'")+1);
p = z.substring(0,z.indexOf("'"));
x[0].setAttribute("href",p);
x[0].setAttribute("target","_blank");
@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,