Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dainiuxt
dainiuxt / functions.php
Created March 24, 2017 09:36
Add custom code before post content via functions.php
<?php
function my_before($content) {
if (is_single()) {
$beforecontent = previous_post_link(); ?> | <?php next_post_link();
$content = $beforecontent . $content;
return $content;
}
return $content;
}
add_filter('the_content', 'my_before');
@dainiuxt
dainiuxt / style.css
Created March 23, 2017 14:34
Divi portfolio grid view image resize. Just change the padding-top until you get the desired aspect ratio.
.et_portfolio_image {
padding-top: 100%;
}
.et_portfolio_image img {
position: absolute;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
@dainiuxt
dainiuxt / index.html
Created March 22, 2017 15:24
The object-fit property defines how an element responds to the height and width of its content box. It's intended for images, videos and other embeddable media formats in conjunction with the object-position property. Used by itself, object-fit lets us crop an inline image by giving us fine-grained control over how it squishes and stretches insi…
<div class="original-image">
<p>original image</p>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/14179/image.png">
</div>
<div class="image">
<p>object-fit: fill</p>
<img class="object-fit_fill" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/14179/image.png">
</div>
@dainiuxt
dainiuxt / divi_contactform_submit_button.js
Last active March 22, 2017 14:51
Submit Button Text in contact module can be changed by applying some JavaScript, just follow given steps to achieve the goal. Go to Divi > Theme Option > Integration Paste the given code in Head section
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("button.et_pb_contact_submit").text('<strong>This is it</strong>');
});
</script>
@dainiuxt
dainiuxt / gist:731ffebc9672a600022a
Last active March 24, 2017 10:38
Install packages in R on demand (if require)
if (!require("data.table")) {
install.packages("data.table")
}
if (!require("reshape2")) {
install.packages("reshape2")
}
require("data.table")
require("reshape2")
@dainiuxt
dainiuxt / R trouble.r
Last active March 24, 2017 10:37
R trouble
Problem solved. Faulty code in line 16: geom_line(aes(y = monthly$CumOil, colour = "CumOil, 1000 m3"))
R version 3.1.0 (2014-04-10) -- "Spring Dance"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)
Code:
library("ggplot2")
ggplot(monthly[monthly$Well_N == "NSD1",],aes(Date_m)) +
@dainiuxt
dainiuxt / MSAccessDBConnection.r
Last active November 20, 2019 14:56
Connect MS Access database to R (RStudio) in Windows
library("RODBC") #load package
db<-file.path("C:/path/to/your/database.accdb") #connect database.
#Note the UNIX style slash (/). "\" is "escape character" so all "\"you should replace either with "/" or "\\"
channel<-odbcConnectAccess2007(db) #internal RODBC function
dataSetName<-sqlFetch(channel,"TableName") #read particular table from Access database file.