Let's generate User model and controller.
mix ecto.create # create DB table
mix phx.gen.json Accounts User users email:string password_hash:string # scaffold users structure
function get_avatar_from_service(service, userid, size) { | |
// this return the url that redirects to the according user image/avatar/profile picture | |
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback | |
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px ) | |
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word ) | |
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px ) | |
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word ) | |
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px ) | |
// everything else will go to the fallback | |
// google and gravatar scale the avatar to any site, others will guided to the next best version |
const mapValuesAsync = (obj, asyncFn) => { | |
const keys = Object.keys(obj); | |
const promises = keys.map(k => { | |
return asyncFn(obj[k]).then(newValue => { | |
return {key: k, value: newValue}; | |
}); | |
}); | |
return Promise.all(promises).then(values => { | |
const newObj = {}; | |
values.forEach(v => { |
class ArticleImageUploader < ImageUploader | |
process :fix_exif_rotation | |
process :strip | |
process :convert => 'jpg' | |
process :quality => 85 # Percentage from 0 - 100 | |
version :gallery_thumb do | |
process :resize_to_fill => Settings.images.article_images.processing.gallery_thumb #44x44 | |
end |
let alreadyRun = document.querySelector('body').classList.contains("vl-bookmarklet"); | |
let domainCheck = window.location.origin == "http://legaldiary.courts.ie" | |
function wrap(el, wrapper) { | |
el.parentNode.insertBefore(wrapper, el); | |
wrapper.appendChild(el); | |
} | |
function addStyle(styleString) { | |
const style = document.createElement('style'); |
echo 'kern.maxfiles=20480' | sudo tee -a /etc/sysctl.conf | |
echo -e 'limit maxfiles 8192 20480\nlimit maxproc 1000 2000' | sudo tee -a /etc/launchd.conf | |
echo 'ulimit -n 4096' | sudo tee -a /etc/profile |
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=YOUR-PROFILE-ID"></script> | |
<div class="addthis_default_style"> | |
<a class="addthis_button_facebook_like" fb:like:layout="box_count" fb:like:width="48" fb:like:height="63"></a> | |
<div class="clearfix"></div> | |
<a class="addthis_button_tweet" tw:count="vertical"></a> | |
<div class="clearfix"></div> | |
<a class="addthis_button_google_plusone" g:plusone:size="tall"></a> | |
</div> |
#taken from http://www.vipan.com/htdocs/htaccess.shtml | |
# Place a .htaccess file in each directory you want to protect. | |
######################################################################## | |
# SECURITY / ACCESS CONTROL # | |
# If the web server's AllowOverride allows AUTHCONFIG to be overridden # | |
######################################################################## | |
# | |
# Save both .htpasswd and .htgroup files in a directory above "documentroot" directory | |
# (e.g. not in or below /apache/htdocs) but could be below "serverroot" directory |
//Thank to @Formstone https://github.com/Formstone/Selecter/blob/master/src/jquery.fs.selecter.js | |
if (window.document.createEvent) { // All | |
var evt = window.document.createEvent("MouseEvents"); | |
evt.initMouseEvent("mousedown", false, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); | |
el.dispatchEvent(evt); | |
} else if (el.fireEvent) { // IE | |
el.fireEvent("onmousedown"); | |
} |
def extract_stuff(stuff, path) | |
path.empty? stuff : extract_stuff(stuff[path.shift], path) | |
end |