Skip to content

Instantly share code, notes, and snippets.

View abachuk's full-sized avatar
✍️
dev manager by day, writing code at night

Alex Bachuk abachuk

✍️
dev manager by day, writing code at night
View GitHub Profile
@abachuk
abachuk / server.js
Created June 26, 2017 21:47
node.js using fileUploadMiddleware for streaming files to CDN
import multer from 'multer';
import cloudinary from 'cloudinary';
import fileUploadMiddleware from './fileUploadMiddleware';
/* your servrer init and express code here */
cloudinary.config({
cloud_name: 'xxx',
api_key: 'xxxx',
api_secret: 'xxxxx',
import axios from 'axios';
import cloudinary from 'cloudinary';
export default function fileUploadMiddleware(req, res) {
cloudinary.uploader.upload_stream((result) => {
axios({
url: '/api/upload', //API endpoint that needs file URL from CDN
method: 'post',
data: {
url: result.secure_url,
import Ember from 'ember';
// because it's loading through browserify, we're preficing it with npm:
import AWS from 'npm:aws-sdk'
// It's recommended to keep all your API keys in the environment.js file
// and pass them through environment variables
import config from '../config/environment';
const ses = new AWS.SES({
apiVersion: '2010-12-01',
accessKeyId: config.aws.accessKeyId,
actions: {
sendContactForm() {
// Getting input values.
// TODO: add validation before trying to save the values.
const submittedForm = {
name: this.get('name'),
email: this.get('email'),
company: this.get('company'),
phone: this.get('phone'),
message: this.get('message'),
import express from 'express';
import axios from 'axios';
import multer from 'multer';
const app = express();
/**
... express.js boilerplate
routes, middlewares, helpers, loggers, etc
**/
// Redux action
export function uploadSuccess({ data }) {
return {
type: 'UPLOAD_DOCUMENT_SUCCESS',
data,
};
}
export function uploadFail(error) {
return {
function add (a,b) {
return a+b;
}
@abachuk
abachuk / index.php
Created June 7, 2015 18:45
WordPress plugin extending CMB2 metaboxes
<?php
/*
Plugin Name: NDM metaboxes
Description: portfolio metaboxes for NDM
Version: 0.11
Author: Alex Bachuk
Author URI: http://alexbachuk.com
License: GPL2
*/
?>
// The actual grunt server settings
connect: {
options: {
port: 9000,
hostname: 'localhost',
livereload: 35729
},
proxies: [{
context: '/api', // the context of the data service
host: 'mydomain.com/apis/', // wherever the data service is running
@abachuk
abachuk / swipe.js
Created September 26, 2013 18:18
simple swipe wvents
$.fn.swipeEvents = function() {
return this.each(function() {
var startX,
startY,
$this = $(this);
$this.bind('touchstart', touchstart);