Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Learning the sh*t out of things

Noud Adrichem noudadrichem

💻
Learning the sh*t out of things
View GitHub Profile
View removeUnusedLayerStyles.js
function cleanLayerStyless(array) {
var layers = []
array.forEach(function(layer) {
if (layer.class() == 'MSShapeGroup') layers.push(layer)
})
for (var i = 0; i < layers.length; i++) {
layers.forEach(function(layer, index) {
var fills = layer.style().fills()
fills.forEach(function(fill, fillIndex) {
@noudadrichem
noudadrichem / sketch-plugin-dialog-window.js
Created Jan 10, 2018
A function that creates a simple dialog window with CocoaScript
View sketch-plugin-dialog-window.js
function createDialogWindow(context) {
// Setup the window
var alert = COSAlertWindow.new()
alert.setMessageText("Example modal")
alert.addButtonWithTitle("Run")
alert.addButtonWithTitle("Cancel")
// Create initial view panel
var width = 425
View sketch-plugin-file-tree
example.sketchPlugin
└── Contents
├── Resources
└── Sketch
├── manifest.json
└── yourFunction.js
View city-lights-hyper-theme.js
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// Choose either "stable" for receiving highly polished,
// or "canary" for less polished but more frequent updates
updateChannel: 'stable',
View recursive-layer-search-in-selection.js
var selection = context.selection
var shapeGroups = []
function searchInLayer(layer) {
switch (layer.class())) {
case MSPage:
case MSLayerGroup:
case MSArtboardGroup:
let sublayers = layer.layers()
for (let i = 0; i < sublayers.count(); i++) {
View seconds-to-hour-minute-seconds.js
secondsToHourMinuteSecond(totalSeconds) {
let hour = Math.floor(totalSeconds / 3600);
let minute = Math.floor(totalSeconds % 3600 / 60);
let seconds = Math.floor(totalSeconds % 3600 % 60);
return `${('0' + hour).slice(-2)}:${('0' + minute).slice(-2)}:${('0' + seconds).slice(-2)}`
}
/*
returns total seconds to hh:mm:ss value.
@noudadrichem
noudadrichem / .editorconfig
Created Apr 16, 2018
python editorconfig for atom
View .editorconfig
root = true
[*.py]
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8
@noudadrichem
noudadrichem / allow-svg-mime-types.php
Created Apr 28, 2018
allows SVG mime types in Wordpress, put this snippet in your themes `functions.php` and you're done.
View allow-svg-mime-types.php
<?php
# mime = meme
function cc_mime_types($memes) {
$memes['svg'] = 'image/svg+xml';
return $memes;
}
add_filter('upload_mimes', 'cc_mime_types');
function fix_svg() {
View city-lights.terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGKyxYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKcHCBMZHSQoVSRudWxs1QkKCwwNDg8QERJcTlNDb21wb25lbnRzVU5TUkdCXE5T
Q29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29sb3JTcGFjZVYkY2xhc3NPECgwLjIwNzg0MzEz
NzMgMC4yNDcwNTg4MjM1IDAuMjg2Mjc0NTA5OCAxTxAnMC4xNTc1NDY3NDM4IDAuMTg4
View fixNav.js
const nav = document.querySelector('#nav');
const topOfNav = nav.offsetTop
function fixNav() {
if(window.scrollY >= topOfNav) {
document.body.classList.add('fixed-nav')
document.body.style.paddingTop = nav.offsetHeight + 'px';
} else {
document.body.classList.remove('fixed-nav')
document.body.style.paddingTop = 0;