Skip to content

Instantly share code, notes, and snippets.

@simkessy
simkessy / getfile.js
Last active August 9, 2017 00:10
Get files in document set
// Get working group files
getFiles: function(id) {
var d = $.Deferred();
var opts = {
listName: "WgDocuments",
CAMLQuery: "<Query><OrderBy><FieldRef Name='Created' Ascending='False'/></OrderBy><Where><And><Eq><FieldRef Name='FSObjType' /><Value Type='Integer'>0</Value></Eq><IsNotNull><FieldRef Name='ID' /></IsNotNull></And></Where></Query>",
CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='RecursiveAll' /></QueryOptions>",
CAMLRowLimit: 5
}
/*
* HillbillyTabs.2013 - Place SharePoint 2013 Web Parts in Tabs
* Version 3.0
* @requires jQuery v1.7 or greater
* @requires jQueryUI v1.11 or greater
* @requires jQuery.cookie
*
* Copyright (c) 2013-2015 Mark Rackley
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
@simkessy
simkessy / updateItems.js
Created April 23, 2017 00:44
pnp-js-core: Using Batching to checkout, update and checkin selected list items
// Update files
function updateItems (isTrue) {
// Get selected files from list
var selectedItems = SP.ListOperation.Selection.getSelectedItems().map(x => x.id)
var myFieldValue = isTrue ? "true" : "false";
var batch = $pnp.sp.createBatch(); // Create batch object
var fileRefs = []; // Store selected files reference
var documentLibrary = $pnp.sp.web.lists.getByTitle("Documents"); // Get document library
// Get fileRef from selected items
var GetSites = function () {
var allSites = []
var d = $.Deferred();
//MAKE CALL FOR ALL SITES
var getCollectionSites = $().SPServices({operation: "GetAllSubWebCollection"});
//HANDLE CALL PROMISE
getCollectionSites.then(success,fail);
//EXTRACT NECESSARY PROPERTIES FROM RESPONSE
function success(resolve) {
var result = $(resolve);
<%-- The following 4 lines are ASP.NET directives needed when using SharePoint components --%>
<%@ Page Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" MasterPageFile="~masterurl/default.master" Language="C#" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%-- The markup and script in the following Content element will be placed in the <head> of the page --%>
<asp:Content ContentPlaceHolderID="PlaceHolderAddition
class Availability < ActiveRecord::Base
# Associations
belongs_to :facility
has_one :venue, through: :facility
# Scopes for search filters
scope :close_to, -> (venues) {where{facility.venue_id.in venues}}
scope :activity, -> (activity) {where{facility.activities.name.in activity}}
scope :start_date, -> (datetime) {where{ start_time >= datetime }}
@simkessy
simkessy / service.rb
Created October 21, 2015 04:15
Trying to access instance variable from service class
class MyService
def initialize user, card, pricing_service
@user = user
end
end
# Initialize
MyService.new(current_user)
# Trying to return value outside controller, maybe in the console for example
{
id: ch_16y7ULJIRogBQY6KCRms4GAZ
object: "charge"
amount: 3344
amount_refunded: 0
application_fee: null
balance_transaction: "txn_16y7ULJIRogBQY6KGAKRKRmm"
captured: true
created: 1445375865
currency: "cad"
@simkessy
simkessy / User.rb
Last active October 7, 2015 02:49
Trying to have Rails Admin timezone match with form timezone select
validates_inclusion_of :time_zone, in: ActiveSupport::TimeZone.us_zones.map { |z| z.name },
message: "is not a valid time zone",
allow_blank: true
# This allows me to display the time_zone as a dropdown in rails admin instead of a text box
TIMEZONES = ActiveSupport::TimeZone.us_zones.map { |z| z.name }
def time_zone_enum
TIMEZONES.each_with_index.to_a
end