Skip to content

Instantly share code, notes, and snippets.

View serbiant's full-sized avatar

Vladimir serbiant

  • Shypple
  • Rotterdam, the Netherlands
View GitHub Profile
@nathansmith
nathansmith / [1] convertToMarkup.js
Last active March 11, 2025 10:27
Handy utilities for dealing with `<div contenteditable="true">` areas.
// Helpers.
import { convertToText } from './';
/*
You would call this when receiving a plain text
value back from an API, and before inserting the
text into the `contenteditable` area on a page.
*/
const convertToMarkup = (str = '') => {
return convertToText(str).replace(/\n/g, '<br>');
@mlanett
mlanett / rails http status codes
Last active February 3, 2025 11:36
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@ronan-mch
ronan-mch / hash to xml
Created June 28, 2013 07:58
recursive function to render xml from a multidimensional hash using Nokogiri.
def write_xml(hash)
builder = Nokogiri::XML::Builder.new do |xml|
hash_to_xml(hash, xml)
end
render xml: builder
end
def hash_to_xml(hash, xml)
hash.each do |key, value|
if value.is_a? String
@kapkaev
kapkaev / gist:4619127
Created January 24, 2013 09:30
MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. Resque
$ redis-cli
> config set stop-writes-on-bgsave-error no
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}