This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"<?php If ... endif": { | |
"prefix": "pif", | |
"body": [ | |
"<?php if (${1:condition}): ?>", | |
"\t${0:<!-- code here -->}", | |
"<?php endif; ?>" | |
], | |
"description": "If endif block inside HTML" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
bash /path/to/ssl-deploy-hook -d example.com -p "NEW-PASSPHRASE-FOR-CERTIFICATE-PRIVATE-KEY" | |
# Example Crontab | |
# 36 2,14 * * * root /opt/certbot-auto -q renew --deploy-hook /path/to/call-ssl-deploy-hook # this script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
// IMPORTANT - Replace the following line with your path to the escpos-php autoload script | |
require_once __DIR__ . '\..\..\autoload.php'; | |
use Mike42\Escpos\PrintConnectors\NetworkPrintConnector; | |
use Mike42\Escpos\PrintConnectors\FilePrintConnector; | |
use Mike42\Escpos\Printer; | |
class ReceiptPrint { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def select_from_chosen(item_text, options) | |
field = find_field(options[:from], visible: false) | |
option_value = page.evaluate_script("$(\"##{field[:id]} option:contains('#{item_text}')\").val()") | |
page.execute_script("value = ['#{option_value}']\; if ($('##{field[:id]}').val()) {$.merge(value, $('##{field[:id]}').val())}") | |
option_value = page.evaluate_script("value") | |
page.execute_script("$('##{field[:id]}').val(#{option_value})") | |
page.execute_script("$('##{field[:id]}').trigger('liszt:updated').trigger('change')") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def select_from_chosen(item_text, options) | |
field = find_field(options[:from]) | |
option_value = page.evaluate_script("$(\"##{field[:id]} option:contains('#{item_text}')\").val()") | |
page.execute_script("$('##{field[:id]}').val('#{option_value}')") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Class_Utility { | |
// Echoes headings for each class with an unordered list of public methods | |
public static function echo_subclasses_and_methods($parent, $exclude_classes = null, $exclude_methods = null) | |
{ | |
// Loop through results to echo "pretty" output | |
foreach (static::get_subclasses_and_methods($parent, $exclude_classes, $exclude_methods) as $class) { | |
echo "<h2>".$class['name']."</h2>"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Running Seeds | |
# From console (for development/production environmnts) | |
# $ rake db:seed | |
# Seeding tests (rspec) | |
# Create helper method | |
def load_seed_data | |
load "#{Rails.root}/db/seeds.rb" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def candidate_queue | |
self.campaigns.collect do |x| | |
x.candidates.select {|y| y.owners.compact.include?(self) } | |
end.flatten.sort! {|a,b| a.updated_at <=> b.updated_at } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# u = User.first | |
# u.role_id # => 1 | |
# Desired output | |
# u.role # => "Administrator" | |
# Obvious implementation | |
def role | |
case self.role_id | |
when 1 |
NewerOlder