Skip to content

Instantly share code, notes, and snippets.

View hgezim's full-sized avatar

Gezim Hoxha hgezim

View GitHub Profile
function bufferShare() {
const url = encodeURIComponent(window.location.href);
const title = encodeURIComponent(window.document.title);
const bufferUrl = `https://buffer.com/add?url=${url}&text=${title}`;
window.open(bufferUrl);
}
bufferShare();
@hgezim
hgezim / debugging_filters_in_wp.php
Created September 3, 2018 19:50
This function displays the hooks attached on a filter so you can see what's messing you up!
<?php
function viper_debug_filter( $filter ) {
add_filter( $filter, function( $value ) {
global $wp_filter;
$filters = array();
foreach ( (array) $wp_filter[ current_filter() ]->callbacks as $priority => $functions ) {
foreach ( (array) $functions as $function => $args ) {
$filters['Priority ' . $priority][] = $args;
@hgezim
hgezim / download_drip_broadcasts.py
Created September 1, 2018 20:41
Download Drip Broadcasts for Backup
import requests
from requests.auth import HTTPBasicAuth
import os
import json
# TODO: replace DRIP TOKEN, :account_id, BACKUP_DIR
broadcasts = requests.get('https://api.getdrip.com/v2/:account_id/broadcasts',
auth=HTTPBasicAuth('DRIP TOKEN', ''),
headers={
Last login: Thu Nov 12 13:17:48 on ttys013
ssh -p 64771 [email protected]:frontend gezim$ ssh -p 64771 [email protected]
The authenticity of host '[54.158.55.14]:64771 ([54.158.55.14]:64771)' can't be established.
ECDSA key fingerprint is SHA256:ZR/CnZW46nEaaJBuNh9mEWZqvjxP9ltuVHwSYLWrL/Y.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[54.158.55.14]:64771' (ECDSA) to the list of known hosts.
Last login: Thu Nov 12 20:28:28 2015 from 10.155.244.26
ubuntu@box440:~$ ps aux | grep jest
ubuntu 12528 0.0 0.0 4440 624 pts/3 S+ 20:29 0:00 sh -c gulp env unsymlink; jest --maxWorkers 4
ubuntu 12539 49.7 0.0 1092680 208932 pts/3 Sl+ 20:29 0:04 node /home/ubuntu/frontend/node_modules/.bin/jest --maxWorkers 4
class Post(models.Model):
title = models.CharField(max_length=500)
hn_id = models.CharField(max_length=50, unique=True)
points = models.IntegerField(null=True)
comment_count = models.IntegerField()
comments_link = models.URLField()
date = models.DateTimeField() # datetime that HN post was posted
date_scraped = models.DateTimeField(auto_now_add = True) # date object was scraped from HN
date_modified = models.DateTimeField(auto_now = True) # date this object has been updated (rescraped)
# link the story is linked to -- HN links can be long so set max_length to 2000
@hgezim
hgezim / comment_cwd.py
Last active December 12, 2015 06:48
Python script that gets every line in every file in the current directory and appends '//' to the front.
"""Python script that gets every line in every file in the current directory and appends '//' to the front."""
import os
os.listdir('.')
file_names = os.listdir('.')
for file in file_names:
opened_file = open(file)
lines = opened_file.readlines()
for line in lines:
print "// %s" % (line),
#!/bin/bash
## LockFile function ##
# example:
# main() {
# LockFile create
# RunScriptStuff
# LockFile remove
# }
#Globals
@hgezim
hgezim / JavaScript Community FAQs.md
Last active March 17, 2020 01:52
JavaScript Community FAQs

Google+ JavaScript Community FAQs

These are frequently asked question in the JavaScript Community.

  1. How do I do thing in Java?

That's a great question! Please find a Java community on Google+ to ask. JavaScript is not the same as Java. Here's a good explanation of the differences between Java and JavaScript: http://www.dannyg.com/ref/javavsjavascript.html.

Meteor.methods
sendListToEmails: (from_email, to_emails, list_id, uid) ->
Meteor.http.post('blah')
blah_blue: () ->
console.log "Sup."
create_user: () ->
console.log "In createuser Meteor method."
TeamDoListRouter = Backbone.Router.extend
initialize: (options) ->
# IMPORTANT: These get matched in the reverse order that they show up
@route(/\?*/, "home") #Match / followed by a question mark or 0 question marks
@route(/([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})/, "list") # Match a GUID
home: () ->
Session.set('page', 'home')
initHome()
this.navigate ''