Skip to content

Instantly share code, notes, and snippets.

View markshust's full-sized avatar
🤓
Currently exploring building production apps with Claude Code & AI.

Mark Shust markshust

🤓
Currently exploring building production apps with Claude Code & AI.
View GitHub Profile
<?php
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits

Keybase proof

I hereby claim:

  • I am markoshust on github.
  • I am markoshust (https://keybase.io/markoshust) on keybase.
  • I have a public key whose fingerprint is 1197 0D20 86BD 2304 091D 2184 00DB 310B BF4B A5FB

To claim this, I am signing this object:

@markshust
markshust / data-install-0.0.0.1.php
Created July 9, 2015 12:39
update magento static block programmatically through upgrade scripts
<?php
/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();
$connection = $installer->getConnection();
$identifier = 'id-goes-here';
$title = 'Title Goes Here';
@markshust
markshust / GIF-Screencast-OSX.md
Last active September 14, 2015 12:18 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@markshust
markshust / gist:cdaa272558627e238a8e
Created November 27, 2015 20:10
meteor oplog user setup, mongodb 2.6+
db.createUser({user: "oplogger", pwd: "PasswordForOplogger", roles: [{role: "read", db: "local"}]})
@markshust
markshust / video.js
Last active December 30, 2015 21:48
underscore mixin to mutate html containing youtube or vimeo video url's to embed html
_.mixin({
mutateVideoUrlsToEmbeds: function(html) {
let embed = '';
const youtubeRegEx = /(?:http?s?:\/\/)?(?:www\.)?(?:youtu\.be|youtube\.com)\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=)?((\w|-){11})/g;
const vimeoRegEx = /(?:http?s?:\/\/)?(?:www\.)?(?:vimeo\.com)\/(.*)/g;
if (youtubeRegEx.test(html)) {
embed = '<iframe width="360" height="270" src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>';
html = html.replace(youtubeRegEx, embed);
}
@markshust
markshust / lbtobr.js
Last active December 14, 2015 18:56
underscore mixin to convert line breaks to br tags
_.mixin({
lbToBr: function(html) {
html = html.replace(/(?:\r\n|\r|\n)/g, '<br />');
return html;
}
});
@markshust
markshust / imagetoimg.js
Created December 14, 2015 18:56
underscore mixin to convert image urls to img tags
_.mixin({
imageToImg: function(html) {
const regEx = /(https?:\/\/.*\.(?:jpg|jpeg|gif|png))/g;
if (regEx.test(html)) {
const embed = '<img src="$1" />';
html = html.replace(regEx, embed);
}
return html;
@markshust
markshust / CustomDialog.jsx
Last active September 15, 2016 09:20
custom dialog box using reactjs version of material design (material-ui)
const { Dialog, FlatButton, RaisedButton } = mui;
CustomDialog = React.createClass({
getInitialState() {
return {
showDialog: false
};
},
handlePrompt() {
@markshust
markshust / gist:c3db6c1d48d6c723b18c
Created January 6, 2016 21:12
mupx ssl termination setup for ssls.com
cat domain.com.crt domain.com.ca-bundle > domain.com.bundle.crt