Skip to content

Instantly share code, notes, and snippets.

View fadamakis's full-sized avatar
👋
Hello, World!

Fotis Adamakis fadamakis

👋
Hello, World!
View GitHub Profile
@fadamakis
fadamakis / appendHtml.js
Created October 25, 2012 10:04
Append html with jquery
$('<div>').addClass('comment').attr('data-id',3)
.append(
$('<div>').addClass('photo').append(
$('<img>').attr('src','url').attr('width','50').attr('height','50'))
).append(
$('<div>').addClass('name').append(
'Username'
)
).append(
$.ajax({
type:"GET",
url:baseurl,
beforeSend:function (xhr) {
var creds = username + ":" + password;
var basicScheme = btoa(creds);
var hashStr = "Basic " + basicScheme;
xhr.setRequestHeader('Authorization', hashStr);
xhr.setRequestHeader('accept', 'application/json');
},
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
@fadamakis
fadamakis / cloudSettings
Last active February 26, 2019 08:44
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-02-26T08:44:01.263Z","extensionVersion":"v3.2.5"}
# Delete all local merged branches
git branch --merged | egrep -v "(^\*|master|develop)" | xargs git branch -d
# Delete All local branches except master and develop
git branch | egrep -v "(^\*|master|develop)" | xargs git branch -d
# Delete all stashes
git stash clear
# Delete all local tags
@fadamakis
fadamakis / asyncComponent.js
Created January 30, 2021 13:11
Handling Loading State - Long format
const AsyncComponent = () => ({
// The component to load (should be a Promise)
component: import('./MyComponent.vue'),
// A component to use while the async component is loading
loading: LoadingComponent,
// A component to use if the load fails
error: ErrorComponent,
// Delay before showing the loading component. Default: 200ms.
delay: 200,
// The error component will be displayed if a timeout is
@fadamakis
fadamakis / vOnceComponent.js
Created January 30, 2021 13:27
Cheap Static Components with v-once
Vue.component('terms-of-service', {
template: `
<div v-once>
<h1>Terms of Service</h1>
... a lot of static content ...
</div>
`
})
@fadamakis
fadamakis / modifiers.js
Last active January 30, 2021 13:52
Event & Key Modifiers
on: {
'!click': this.doThisInCapturingMode,
'~keyup': this.doThisOnce,
'~!mouseover': this.doThisOnceInCapturingMode
}
<div id="dynamicexample">
<h3>Scroll down inside this section ↓</h3>
<p v-pin:[direction]="200">I am pinned onto the page at 200px to the left.</p>
</div>
Vue.directive('pin', {
bind: function (el, binding, vnode) {
el.style.position = 'fixed'
var s = (binding.arg == 'left' ? 'left' : 'top')
el.style[s] = binding.value + 'px'
}
<my-component inline-template>
<div>
<p>These are compiled as the component's own template.</p>
<p>Not parent's transclusion content.</p>
</div>
</my-component>