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/zsh | |
# Iterate over files in the directory | |
for filename in *; do | |
# Check if the filename is a regular file | |
if [[ -f "$filename" ]]; then | |
# Extract filename and extension | |
base_filename=$(basename "$filename") | |
extension="${base_filename##*.}" | |
base_filename="${base_filename%.*}" |
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
// Implementation in ES6 | |
function pagination(c, m) { | |
var current = c, | |
last = m, | |
delta = 2, | |
left = current - delta, | |
right = current + delta + 1, | |
range = [], | |
rangeWithDots = [], | |
l; |
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
jQuery -> | |
$('[id^="best_in_place_your_object_"],[id$="address"]').on 'best_in_place:update', (event) -> | |
$address = $(event.target) | |
$address.data('bestInPlaceEditor').original_content = $address.html() | |
$address.html $address.html().replace(/[\n\r]+/g, '<br>') |
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
(($) -> | |
$.fn.clearForm = -> | |
@find(":input").each -> | |
switch @type | |
when "password", "select-multiple" | |
, "select-one" | |
, "text" | |
, "textarea" | |
$(this).val "" | |
when "radio", "checkbox" |
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
const path = require('path') | |
const webpack = require('webpack') | |
const HtmlWebpackPlugin = require('html-webpack-plugin') | |
// add | |
const Dashboard = require('webpack-dashboard'); | |
const DashboardPlugin = require('webpack-dashboard/plugin'); | |
const dashboard = new Dashboard(); | |
// add |
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
Mongoid.connect_to 'mongoid-3144' | |
class Post | |
include Mongoid::Document | |
field :name | |
embeds_many :comments | |
accepts_nested_attributes_for :comments | |
# This line somehow triggers the bug; commenting it out fixes the bug, wierd. |
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
# encoding: UTF-8 | |
Pry.config.editor = "vim" | |
Pry.config.pager = false | |
Pry.config.commands.alias_command "lM", "ls -M" | |
if defined?(Encoding) then | |
Encoding.default_external = 'utf-8' | |
Encoding.default_internal = 'utf-8' | |
else | |
$KCODE = 'utf-8' |
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
(function($) { | |
$.fn.clearForm = function() { | |
return this.find(':input').each(function() { | |
switch (this.type) { | |
case 'password': | |
case 'select-multiple': | |
case 'select-one': | |
case 'text': | |
case 'textarea': | |
return $(this).val(''); |
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
Taken from http://stackoverflow.com/questions/244243/how-to-reset-postgres-primary-key-sequence-when-it-falls-out-of-sync. | |
--drop function IF EXISTS reset_sequence (text,text) RESTRICT; | |
CREATE OR REPLACE FUNCTION "reset_sequence" (tablename text,columnname text) RETURNS bigint --"pg_catalog"."void" | |
AS | |
$body$ | |
DECLARE seqname character varying; | |
c integer; | |
BEGIN | |
select tablename || '_' || columnname || '_seq' into seqname; |
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
ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, start, finish, id, payload| | |
if payload[:exception] | |
name, message = *payload[:exception] | |
Uhoh::Failure.create!(:message => message) | |
end | |
end |
NewerOlder