Skip to content

Instantly share code, notes, and snippets.

@frank4565
frank4565 / zeteroZhEn.js
Created January 27, 2015 17:49
Zetero assign Language between Chinese and English
var fieldName = "language";
var en = "en";
var zh = "zh"
var getFieldID = function(item, fieldName) {
var fieldID = Zotero.ItemFields.getID(fieldName);
var mappedFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(item.itemTypeID, fieldName);
return mappedFieldID ? mappedFieldID : fieldID
}
From a13aeb2446091a9bbd769c164d16b13d7f139ab4 Mon Sep 17 00:00:00 2001
From: Junlu Cheng <frank4565@gmail.com>
Date: Wed, 5 Nov 2014 19:20:34 +0800
Subject: [PATCH] Fixed warnings about [NSApp delegate].
---
SquirrelApplicationDelegate.m | 2 +-
SquirrelInputController.m | 28 ++++++++++++++--------------
main.m | 8 ++++----
3 files changed, 19 insertions(+), 19 deletions(-)
// Credits
// http://hi.baidu.com/2hill/item/efa5c2f49b9601cd521c263d
var Default_isFT = 0 //默认是否繁体,0-简体,1-繁体
var StranIt_Delay = 50 //翻译延时毫秒(设这个的目的是让网页先流畅的显现出来)
//-------代码开始,以下别改-------
//转换文本
function StranText(txt,toFT,chgTxt)
{
void swap(int *a, int i, int j)
{
int t = a[i];
a[i] = a[j];
a[j] = t;
}
void siftup(int* a, int n)
{
for (int c = n; a[c/2] < a[c] && c/2 > 0; c /= 2) {
@frank4565
frank4565 / 2.7.cpp
Created February 18, 2014 08:56
2.7 Implement a function to check if a linked list is a palindrome.
#include<iostream>
using namespace std;
struct Node
{
int data;
Node *next;
Node(int data, Node *next) {
@frank4565
frank4565 / 2.6.cpp
Created February 18, 2014 07:37
2.6 Given a circular linked list, implement an algorithm which returns the node at the beginning of the loop.
#include<iostream>
using namespace std;
struct Node
{
int data;
Node *next;
Node(int data, Node *next) {
@frank4565
frank4565 / 2.5.cpp
Created February 17, 2014 09:14
2.5 You have two numbers represented by a linked list, where each node contains a single digit. Thedigits are stored in reverse order, such that the 1'sdigit isat the head of the list. Write a function that adds the two numbers and returns the sum as a linked list. SOLUTION FOLLOW UP Suppose the digits are stored in forward order. Repeat the abo…
#include<iostream>
using namespace std;
struct Node
{
int data;
Node *next;
Node(int data, Node *next) {
@frank4565
frank4565 / 2.4.cpp
Created February 14, 2014 09:38
2.4 Write code to partition a linked list around a value x, such that all nodes less than x come before alt nodes greater than or equal to x.
#include<iostream>
using namespace std;
struct Node
{
int data;
Node *next;
Node(int data, Node *next) {
@frank4565
frank4565 / 2.3.cpp
Created February 14, 2014 07:50
2.3 Implement an algorithm to delete a node in the middle of a singly linked list, given only access to that node.
#include<iostream>
using namespace std;
struct Node
{
int data;
Node *next;
Node(int data, Node *next) {
@frank4565
frank4565 / 2.2.cpp
Created February 13, 2014 12:51
2.2 Implement an algorithm to find the kth to last element of a singly linked list.
#include<iostream>
using namespace std;
struct Node
{
int data;
Node *next;
Node(int data, Node *next) {