Skip to content

Instantly share code, notes, and snippets.

View lukasborawski's full-sized avatar

Lukas Borawski lukasborawski

View GitHub Profile
@lukasborawski
lukasborawski / api.js
Last active January 25, 2018 14:40
Axios API Call Shorthand
import axios from 'axios'
export default {
get (path) {
if (path.indexOf('/') !== 0) {
path = '/' + path
}
return axios
.get('//' + process.env.apiHost + ':' + process.env.apiPort + '/api' + path)
.then(({data}) => data)
@lukasborawski
lukasborawski / setup.md
Created October 2, 2017 14:44 — forked from developius/README.md
Set up GitHub push with SSH keys

Create a repo. Make sure there is at least one file in it (even just the README) Generate ssh key:

ssh-keygen -t rsa -C "[email protected]"

Copy the contents of the file ~/.ssh/id_rsa.pub to your SSH keys in your GitHub account settings. Test SSH key:

ssh -T [email protected]
@lukasborawski
lukasborawski / index.js
Last active October 2, 2017 14:45
Scroll to Element for Angular 2
scrollToBottom () {
function offset(el:any) {
let rect = el.getBoundingClientRect(),
scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,
scrollTop = window.pageYOffset || document.documentElement.scrollTop;
return { top: rect.top + scrollTop, left: rect.left + scrollLeft }
}
let content = document.getElementById('content')
if (content) {
let offsetTop = offset(content).top
@lukasborawski
lukasborawski / index.component.js
Last active December 18, 2018 10:21
Angular 2 DOM Mutation Observer with Event Emmiter
observeDOMChanges() {
this.observer = new MutationObserver(mutations => {
mutations.forEach(function(mutation) {
EventEmmiter.emit(true)
});
});
var config = { attributes: true, childList: true, characterData: true };
this.observer.observe(this.elRef.nativeElement, config);
}
@lukasborawski
lukasborawski / axios.js
Created July 13, 2017 07:50
Nuxt.js Axios Plugin
import * as axios from 'axios'
import { getCookieInClient } from '../util/assist'
export default ({ app, store, redirect }) => {
// The server-side needs a full url to works
if (process.SERVER_BUILD) {
axios.defaults.baseURL = `http://${process.env.HOST || 'localhost'}:${process.env.PORT || 3000}`
}
@lukasborawski
lukasborawski / appController.js
Last active August 29, 2015 14:17
MVC JavaScript App Structure
var _userForm = {
getElement: {
d: $(document),
f: $('.js-userForm')
},
send: function() {
var self = this;
@lukasborawski
lukasborawski / gulpfile.js
Created November 18, 2014 15:43
Gulp synchronous tasks running.
var gulp = require('gulp');
var async = require('async');
gulp.task('task1', function() {
console.log('1');
});
gulp.task('task2', function(cb) {
setTimeout(function () {
console.log('2');
@lukasborawski
lukasborawski / scripts.js
Last active August 29, 2015 13:59
Facebook competition accessibility from liking of profile.
(function(){
window.fbAsyncInit = function() {
FB.init({
appId : '8547685675671896', // App ID
// channelUrl : 'http(s)://yourdomain.com/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
@lukasborawski
lukasborawski / input.scss
Last active February 12, 2021 11:12
Perfect media-queries screen breakpoints SASS @mixin. Tested on Apple Devices: iPhone4, iPhone5, iPad3, MacBook Pro, iPad Mini. http://sassmeister.com/gist/8529371
$media-queries: true;
@mixin bp($point) {
@if ($media-queries) {
$bp-large-screen: 1824px;
$bp-bigscreen: 1824px;
$bp-ipad-max: 1024px;
$bp-ipad-min: 768px;
$bp-iphone5-max: 568px;
$bp-iphone-max: 480px;
@lukasborawski
lukasborawski / input.scss
Last active January 3, 2016 08:09
Background sprite with retina ready SASS @mixin - http://sassmeister.com/gist/8433951.
$global-sprite-name: 'global_sprite';
$global-sprite-type: "png";
$global-sprite-size: 600px 600px;
@mixin bg-sprite($x: 0, $y: 0, $retina: false) {
$file-type: $global-sprite-type;
background: url('../images/' + $global-sprite-name + '.' + $file-type) $x $y no-repeat;
background-size: 600px 600px;
@if $retina == true {
@media