Skip to content

Instantly share code, notes, and snippets.

/**
*
* This node script will rename all keys according to a given pattern.
*
**/
var redisClient = redis.createClient(config.redis.port, config.redis.host),
search = '*something*', // will rename all keys that contains 'something'
postfix = '.postfix', // all keys will get the postfix '.postfix'
prefix = 'prefix.'; // all keys will get the prefix '.prefix'
@zentuit
zentuit / GamePlayerPrefs
Last active August 29, 2015 14:20
GameStorage and GamePlayerPrefs implementations that use Soomla KeyValueStorage to store the key value pairs
/// Copyright (C) 2012-2014 After Insanity Studios
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
@scaryguy
scaryguy / change_primary_key.md
Last active May 13, 2024 18:43
How to change PRIMARY KEY of an existing PostgreSQL table?
-- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY
ALTER TABLE <table_name> DROP CONSTRAINT <table_name>_pkey;
-- Then change column name of  your PRIMARY KEY and PRIMARY KEY candidates properly.
ALTER TABLE <table_name> RENAME COLUMN <primary_key_candidate> TO id;
@gurdotan
gurdotan / gist:5669730
Last active December 17, 2015 20:48
XHR2 file upload + jQuery deferred
var uploadFormAndFile = function(form, file) {
var formData = new FormData();
formData.append("email", form.email);
formData.append("name", form.name);
formData.append("thumbnail", file);
var uploadDeferred = $.Deferred(),
xhr = new XMLHttpRequest();
(function($) {
function parseImagesFromCSS(doc) {
var i, j,
rule,
image,
pattern = /url\((.*)\)/,
properties = ['background-image', '-webkit-border-image'],
images = {};
if (doc.styleSheets) {
@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active April 2, 2024 20:18
How to publish packages to NPM

Getting Started with NPM (as a developer)

As easy as 1, 2, 3!

Updated:

  • Aug, 08, 2022 update config docs for npm 8+
  • Jul 27, 2021 add private scopes
  • Jul 22, 2021 add dist tags
  • Jun 20, 2021 update for --access=public
  • Sep 07, 2020 update docs for npm version