Skip to content

Instantly share code, notes, and snippets.

View jinweijie's full-sized avatar
🎾

Weijie JIN jinweijie

🎾
View GitHub Profile
@jinweijie
jinweijie / GetLoadableTypes.cs
Created July 24, 2012 00:40
GetLoadableTypes
public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
{
if (assembly == null) throw new ArgumentNullException("assembly");
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException e)
{
return e.Types.Where(t => t != null);
@jinweijie
jinweijie / setValidatorStatus.js
Created July 24, 2012 03:21
setValidatorStatus
function setValidatorStatus(status) {
var validator = document.getElementById('<%=rfvYourValidatorControl.ClientID %>');
//prevent validation while enable the validator
if (status === true && ( validator.enabled || validator.enabled == null)) {
return;
}
ValidatorEnable(validator, status);
}
@jinweijie
jinweijie / GetDelegator.cls
Created October 8, 2012 02:02
Get users whose delegator is current user
Id currentUserId = UserInfo.getUserId();
List<User> delegatedToUsers = [select Id,
Name,
DelegatedApproverId
from User
where DelegatedApproverId=:currentUserId];
system.debug(delegatedToUsers);
@jinweijie
jinweijie / CleanOpportunity.cls
Created October 8, 2012 02:02
Clean Opportunity
Id userId = 'ID_TO_REPLACE';//be careful!
Opportunity[] oppos = [select Id,
Name
from Opportunity
where CreatedById = :userId];
system.debug(oppos.size());
delete oppos;
@jinweijie
jinweijie / gist:3850358
Created October 8, 2012 02:04
Clean CAP
Id userId = 'ID_TO_REPLACE';//be careful!
CAP_ContractApprovalRequest__c[] caps = [select Id,
Name
from CAP_ContractApprovalRequest__c
where CreatedById = :userId];
system.debug(caps.size());
delete caps;
@jinweijie
jinweijie / gist:3871090
Created October 11, 2012 08:55
Recall Approval Request by APEX
Approval.ProcessWorkitemRequest pwr = new Approval.ProcessWorkitemRequest();
pwr.setWorkitemId('04iS00000002qOKIAY');
pwr.setAction('Removed');
Approval.ProcessResult result2 = Approval.process(pwr);
system.debug(result2);
@jinweijie
jinweijie / AppendJS.js
Created October 15, 2012 06:26
appendJS
_honsf.appendJS = function(fileName, onloadHandler) {
var fileref = document.createElement("script");
fileref.setAttribute("type", "text/javascript");
fileref.setAttribute("src", fileName);
if(fileref.readyState){
fileref.onreadystatechange = function () {
/*console.log("state change" + this.readyState);*/
if (this.readyState == 'complete' || this.readyState == "loaded") {
/*console.log("state = complete");*/
@jinweijie
jinweijie / gist:3944231
Created October 24, 2012 05:34
Clean Table by Entity Framework
protected static void CleanTables()
{
List<string> listOfTableNames = new List<string> { "UserRole", "Role", "Address", "User" };
EFContext context = new EFContext();
foreach (var tableName in listOfTableNames)
{
context.ExecuteStoreCommand("DELETE [" + tableName + "]");
}
}
@jinweijie
jinweijie / gist:4029272
Created November 7, 2012 02:35
iFramePostForm
(function ($)
{
$.fn.iframePostForm = function (options)
{
var response,
returnReponse,
element,
status = true,
iframe;
@jinweijie
jinweijie / gist:4139067
Created November 24, 2012 09:52
Google SSL Privacy Real Link
// ==UserScript==
// @name Google SSL Privacy Real Link
// @namespace http://userscripts.org/scripts/show/145014
// @description Mandatory use encryption connection https. Gets rid of almost every google tracking device. Disable the Google search rewrite, always showing and using the real, original, direct link URLs, also to prevent from using redirected pages that might be temporarily unavailable in some area.
// @include http://images.google.*/images*
// @include http://www.google.*/images*
// @include http://www.google.*/webhp*
// @include http://www.google.*/search?*
// @include http://www.google.*/imgres*
// @include http://images.google.*/search?*