Skip to content

Instantly share code, notes, and snippets.

View evalcraciun's full-sized avatar
🎯
Focusing

Craciun Ciprian evalcraciun

🎯
Focusing
View GitHub Profile
@evalcraciun
evalcraciun / is_installed.sh
Created January 24, 2018 18:24 — forked from JamieMason/is_installed.sh
Check if a program exists from a bash script.Thanks to twitter.com/joshnesbitt and twitter.com/mheap for the help with detecting npm packages.
#!/bin/bash
# Functions ==============================================
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
@evalcraciun
evalcraciun / static_server.js
Created December 12, 2016 15:16 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@evalcraciun
evalcraciun / pagination.jade
Created October 31, 2016 13:33 — forked from whitemx/pagination.jade
A Jade HTML mixin to render Bootstrap pagination
//- Pagination mixin
//- ----------------
//- start=# to start pagination at
//- numpages=# links to serve up
//- base=base url before num
//-
//- Example:
//- pagination(1,5,4,'/disc/','?keywords=test')
//- Yields: | < | 3 | 4 | 5 | 6 | 7 | > |
//- « = /disc/2, 3 = /disc/3, 4 = #, .. 7 = /disc/7, » = /disc/8
@evalcraciun
evalcraciun / capybara cheat sheet
Created October 6, 2015 12:46 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@evalcraciun
evalcraciun / gist:56391091aa16f73dccf5
Last active August 29, 2015 14:26 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@evalcraciun
evalcraciun / sidebar
Created September 24, 2014 18:48
Wordpress Custom Archive
<?php
$year_prev = null;
$months = $wpdb->get_results( "SELECT DISTINCT MONTH( post_date ) AS month ,
YEAR( post_date ) AS year,
COUNT( id ) as post_count FROM $wpdb->posts
WHERE post_status = 'publish' and post_date <= now( )
and post_type = 'post'
GROUP BY month , year
ORDER BY post_date DESC");
foreach($months as $month) :
@evalcraciun
evalcraciun / time
Created July 23, 2014 12:28
Get Current Hour with javascript
<!DOCTYPE html>
<html>
<body>
<p>Click the button to display the hour of the time right now.</p>
<button onclick="formatAMPM()">Try it</button>
<p id="demo"></p>
<p id="demon"></p>
.tooltip {
display: block;
position: absolute;
border: 1px solid #D9D9D9;
font: 400 12px/12px Arial;
border-radius: 3px;
background: #fff;
top: -43px;
padding: 5px;
left: -9px;