Skip to content

Instantly share code, notes, and snippets.

View davidtrushkov's full-sized avatar

David Trushkov davidtrushkov

View GitHub Profile

Keybase proof

I hereby claim:

  • I am davidtrushkov on github.
  • I am davidtrushkov (https://keybase.io/davidtrushkov) on keybase.
  • I have a public key whose fingerprint is BEDD 7CC8 F058 929D 346B A68A 4FEA 4EEB 6A59 3BF3

To claim this, I am signing this object:

<select name="state" class="form-control" onchange="$('.lawyer').removeClass('hidden').find('input').attr('autofocus',true)">
<option value="">Select State</option>
<option>Florida</option>
</select>
<div class="lawyer hidden">
<div class="input-group">
<span class="input-group-addon">$</span>
<input name="amount" class="form-control" data-mask="000,000" data-mask-reverse="true" />
</div>
@davidtrushkov
davidtrushkov / Chunk data in Vue JS
Created September 15, 2017 15:10
I show here how to chunk data into rows while looping through them using Vue JS
<template>
<div class="col-sm-12 no-padding">
<div v-if="this.myOffers.length > 0">
<div v-for="chunk in offerChunks">
<div class="row">
<div class="col-sm-4" v-for="offer in chunk">
<!--- Content here ---->
</div>
</div>
</div>
@davidtrushkov
davidtrushkov / Laravel 5.5 multiple select tagging system.
Created September 5, 2017 12:54
Add multiple select tagging in Laravel 5.5 with Select2. Can be reused with different models. Also keeps old data selected on reload and on edit.
// The taggable database table
public function up() {
Schema::create('stateables', function (Blueprint $table) { // In this case taggables
$table->increments('id');
$table->string('stateables_type'); // In this case taggable_type
$table->integer('stateables_id')->unsigned(); // In this case taggables_id
$table->integer('state_id')->unsigned(); // In this case tag_id
$table->timestamps();
});
@davidtrushkov
davidtrushkov / Vue JS + Laravel instant search
Last active May 3, 2017 14:55
Make a simple Vue JS and Laravel instant search
@davidtrushkov
davidtrushkov / Switch image container position in PHP - (WordPress) foreach loop
Created March 27, 2017 15:49
This is how you would switch the image container position in a PHP foreach loop using WordPress.
<div class="container-fluid no-padding hidden-xs">
<?php foreach (get_posts(['post_type' => 'home_project_section', 'posts_per_page'=>100]) as $key => $homeProjects) {
$thumb_id = get_post_thumbnail_id($homeProjects);
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
$thumb_url = $thumb_url_array[0];
$website_url = '/projects/';
$url_to_project = $website_url . $homeProjects->post_name;
?>
<?php if($key % 2 == 0) { ?>
<div class="col-xs-12 no-padding">
@davidtrushkov
davidtrushkov / Dynamically add a active class to tabs
Created February 28, 2017 15:01
Dynamically add a active class to tabs with Javascript. I used this in WordPress.
<script>
$(".nav-link").on("click", function(){
$(".nav").find(".active").removeClass("active");
$(this).parent().addClass("active");
});
</script>
@davidtrushkov
davidtrushkov / gist:d51e5f8683fd16deaa75bfdbd89df0fd
Created February 6, 2017 17:21
Handling Long Words and URLs (Forcing Breaks, Hyphenation, Ellipsis, etc)
.dont-break-out {
/* These are technically the same, but use both */
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
@davidtrushkov
davidtrushkov / gist:a8bdb87227db23b147ddc22136ebc330
Created December 21, 2016 22:32
Make Bootstrap Carousel Dynamic - Laravel 5.3
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
@foreach( $trip->photos as $photo )
<li data-target="#carousel-example-generic" data-slide-to="{{ $loop->index }}" class="{{ $loop->first ? 'active' : '' }}"></li>
@endforeach
</ol>
<!-- Wrapper for slides -->
@davidtrushkov
davidtrushkov / centering.css
Created September 27, 2016 01:06 — forked from gartenfeld/centering.css
Centering without Flexbox
// Add full screen wrapper
.box {
top: 50%;
left: 50%;
margin: 0;
position: absolute;
transform: translate(-50%, -50%);
}