Skip to content

Instantly share code, notes, and snippets.

@devyfriend
devyfriend / init.coffee
Last active July 6, 2018 06:51
atom.io windows setting
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@devyfriend
devyfriend / datatables.js
Created May 15, 2018 02:35
datatables snippets
var tb = $('#table-items').dataTable(), ap = tb.DataTable();
// change data after disable serverside option
// note: data({object:data}) must equal to existing data schemes
tb.dataTable.settings[0].oFeatures.bServerSide = false;
ap.row(0).data({a:'001',b:'abc'}).draw(false);
Verifying my Blockstack ID is secured with the address 1KhjK1vofyWTS8EXk6oJn4KKsim9YjoL8L https://explorer.blockstack.org/address/1KhjK1vofyWTS8EXk6oJn4KKsim9YjoL8L
@devyfriend
devyfriend / js_php.txt
Last active February 27, 2018 20:23
setup axios and php header
// php
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Origin: http://localhost:8080');
// js
window.app = {}
window.axios = require('axios')
window.axios.defaults.withCredentials = true
@devyfriend
devyfriend / font.css
Created November 28, 2017 18:22
base font
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
@devyfriend
devyfriend / post_image.php
Last active October 12, 2017 13:58
wordpress get post image
function post_image_first($post){
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
if(isset($matches[1][0])){
$first_img = $matches[1][0];
if(empty($first_img)){
//Defines a default image
$first_img = false;
@devyfriend
devyfriend / valid.txt
Created July 17, 2017 06:57
validation
SELECT * FROM `table` WHERE email REGEXP '^[A-Za-z0-9._%\-+!#$&/=?^|~]+@[A-Za-z0-9.-]+[.][A-Za-z]+$';
@devyfriend
devyfriend / vue-quill.js
Created May 16, 2017 10:28
vue + quilljs + image resize
<template lang="html">
<div id="editor">
<quill-editor
class="editor-example"
ref="myQuillEditor"
:content="content"
:options="editorOption"
@change="onEditorChange($event)">
</quill-editor>
</div>
@devyfriend
devyfriend / .htaccess
Created February 12, 2017 08:33
htaccess to force to https
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
@devyfriend
devyfriend / randomcolor_php_js.txt
Created February 6, 2017 08:24
generate random color in php and pastel color in javascript
<?php
function random_color_1(){
$rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
return '#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)];
}
function random_color_3(){
return '#'.strtoupper(dechex(rand(0,10000000)));
}
function random_color_2(){
$spread = 25;