Skip to content

Instantly share code, notes, and snippets.

@admataz
admataz / keymap.cson
Created October 6, 2016 11:25
my atom keybindings
'.platform-darwin atom-text-editor':
'cmd-alt-down': 'editor:duplicate-lines'
'cmd-d': 'editor:delete-line'
'cmd-shift-w': 'tabs:CloseAllTabs'
'cmd-?': 'sublime-block-comment:toggle'
'cmd-alt-l': 'linter:togglePanel'
'alt-down': 'editor:move-line-down'
'alt-up': 'editor:move-line-up'
'cmd-l': 'go-to-line:toggle'
@admataz
admataz / package.json
Created November 13, 2016 21:46
package.json for es6 browserify projects
{
"name": "babel",
"version": "1.0.0",
"description": "Website ",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"vendor-js": "mkdirp ./public/js/ && browserify -r VENDOR_DEPENDENCIES | uglifyjs > ./public/js/vendor.js",
"browserify-js": "mkdirp ./public/js/ && browserify --debug -t [babelify --presets [ es2015 ] ] -t brfs -x VENDOR_DEPENDENCIES ./src/index.js --standalone pictoGraphic > ./public/js/pictoGraphic.js",
"process-sass": "mkdirp ./public/css/ && node-sass ./src/sass/main.scss ./public/css/main.css",
@admataz
admataz / wp_custom_fields_rest_support.php
Last active March 10, 2017 16:56
Adding a support to WP REST API for custom fields
<?php
function my_custom_fields_rest_support( $post ) {
$custom = get_post_meta($post['id']);
$fields = array();
foreach($custom as $key=>$value) {
// Assuming Types - could be other Custom Field Types
if(substr($key, 0, 5) == 'wpcf-'){
$fields[str_replace('wpcf-', '', $key)] = $value;
}
}
@admataz
admataz / random-snippets.md
Last active May 27, 2017 19:09
random snippets
@admataz
admataz / generator-pagination.js
Created October 6, 2017 14:31
access a complete paginated recordset, iterating one page at a time using a generator function
/**
* Generator for iterating paginated results
*/
function * Paginator () {
let next = true
let item = null
while (next) {
if (item) {
item = yield item.page + 1
} else {
@admataz
admataz / logPropsChange.js
Created September 12, 2018 21:55
enhancer for recompose to log which props changed in a react component's update
const shouldUpdate = ((props, nextProps) => {
console.log({props})
console.log({nextProps})
Object.keys(nextProps)
.filter(key => {
return nextProps[key] !== props[key]
})
.map(key => {
console.log(
'changed property:',
@admataz
admataz / global-restrictions.conf
Created November 3, 2018 11:45
wordpess running on nginx with https behind a load balancer
include global/restrictions.conf;
# Global restrictions configuration file.
# Designed to be included in any server {} block.
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
<div>
<h1>Adam Davis</h1>
<h2>admataz</h2>
</div>
<div>
<p>Like all forms of human communication, code for computer programs can contain expressiveness, humour, beauty, ugliness… As a coder you recognise beautiful code as a passage that does something with data using brevity and efficiency, where meaning and capability are neatly tucked into a clear and concise passage. That is poetry.</p>
</div>
<img src="https://images.unsplash.com/photo-1559183061-1fd53f7c93e9?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ" height="300" />
@admataz
admataz / hasCamera.js
Last active June 20, 2019 21:27
has camera hook
const [hasCamera, setHasCamera] = useState(false);
useLayoutEffect(() => {
navigator.mediaDevices
.getUserMedia({ video: true })
.then(hasCamera => setHasCamera(true))
.catch(err => setHasCamera(false));
}, []);
We can't make this file beautiful and searchable because it's too large.
row,pid,question,speaker,eval_answer_overall,eval_answer_expertise,eval_candidate_prospect,eval_candidate_collegiality,eval_candidate_overall,eval_mean,condition,pd_region_1,pd_region_2,pd_class_1,pd_class_2,mcpr_1,mcpr_2,mcpr_3,ud_1,ud_2,pd_region,pd_class,mcpr_short,P_gender,P_age,P_ethn,P_ethn_spec,P_UK_born,P_country_birth,P_UK_length_living,P_UK_growup,P_other_native,P_other_native_spec,P_postcode_growup,P_growup_district,P_growup_region,P_postcode_residence,P_residence_district,P_residence_region,P_region,P_self_accent,P_self_accent_change,P_self_occup,P_mom_occup,P_dad_occup,P_edu,P_circle_ethn_sim,P_circle_class_sim,P_ENG_native,Al_familiarity,Al_region,Al_interaction,Al_accent_similarity,DD_familiarity,DD_region,DD_interaction,DD_accent_similarity,GM_familiarity,GM_region,GM_interaction,GM_accent_similarity,JS_familiarity,JS_region,JS_interaction,JS_accent_similarity,PE_familiarity,PE_region,PE_interaction,PE_accent_similarity
1,1067870293,1,DD,8,7,7,7,7,7.2,9,5,5,5,5,5,5,2,5,2,5,5,4,1,71,1,NA,1,NA,N